Here's my FB.ui code:
FB.ui({
method: 'feed',
message: '',
link: 'http://mywebaddress/pathToContent',
picture: 'http://mywebaddress/path开发者_StackOverflow社区ToPhoto/photo.jpg',
display: 'popup'
});
The dialog pops up perfectly, it has the link so no problem... but the picture doesn't show.
I have verified the picture URL is correct. Then I have used the Debugger to test the content URL's open graph tags: it runs flawlessly.
Apparently, the debugger clears some sort of caching. After I use the debugger on the link, the FB.ui
dialog shows the picture just fine.
Is there something I can do about this? The content that users are sharing from my site to Facebook isn't showing the picture like it should, making it a bit annoying for them to use (which is never a good thing!)
Thanks!
You need to change the og:image
in the source of the shared url instead. The picture
parameter is deprecated: https://developers.facebook.com/docs/sharing/reference/feed-dialog/#response
The problem is that you didn't set the URL of your image.
Since you're using a relative URL, the FB.ui is looking for the image in the same folder as the current page. What you should do is put the full URL of your image.
<code>picture: 'http://mywebaddress/pathToPhoto/photo.jpg',</code>
If you don't have the full URL of your image, you can use the following code to get the full URL:
<code>var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
url = url.substring(0, url.lastIndexOf('/') + 1);
url += 'pathToPhoto/photo.jpg';
</code>
精彩评论