开发者

FB.ui feed dialog is "ignoring" the picture attribute, using cached og:image tag instead

开发者 https://www.devze.com 2023-04-13 09:07 出处:网络
Here\'s my FB.ui code: FB.ui({ method: \'feed\', message: \'\', link: \'http://mywebaddress/pathToContent\',

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消