Facebook Feed Dialog not showing Picture

2019-07-29 17:53发布

问题:

I'm using the feed dialog, and the picture that I'm trying to use isn't showing. The dialog comes up with the correct description and caption, but no picture.

Here's my javascript:

FB.ui(
  {
    method: 'feed',
    name: message,
    description: "...",
    caption: "...",
    link: "http://our_domain.com", 
    picture: "https://picture_stored_on_aws"
  },
  (response) ->
    window.close()
)

However, it works when I use a picture stored elsewhere, like this sample from the Facebook dev site: 'http://fbrell.com/f8.jpg'.

I tried removing the https, and still no picture. Anyone else come across this problem? Does it have anything to do with referencing a picture on aws?

回答1:

As you found out, the link you received in S3 has an expiration because the file is not available for the public, only for your own account. You would have to make your image public to use it in your Facebook Feed Dialog.

Log in to the AWS Console, go to S3, find and click on the file you want to use, click on "Properties" button at the top right. You will see a window at the bottom of the page. Click on the "Permissions" tab and make sure that there is a permission for "Open/Download" for "Everyone". When you switch back to the "Details" tab then, you will see a link that is public. With this image link, the picture should also show in your Facebook Feed Dialog.



回答2:

It may be use of https , test with http image URL in array

FB.ui(
  {
    method: 'feed',
    name: message,
    description: "...",
    caption: "...",
    link: "http://our_domain.com", 
    picture: "http://picture_stored_on_aws"
  },
  (response) ->
    window.close()
)


回答3:

I encountered the exact same problem using Django-storages with S3Boto backend. What solved if for me was removing all the GET parameters so if your original generated S3 link was:

https://[your account].s3.amazonaws.com/yourpic.jpg?Signature=[...]&Expires=[...]&AWSAccessKeyId=[...]

you need to parse it to:

https://[your account].s3.amazonaws.com/yourpic.jpg

This worked for me, I hope it helps someone else.