FB.ui 提要对话框被“忽略”图片属性,使用缓存的 og:image 标签代替

发布于 2024-12-10 00:25:06 字数 466 浏览 1 评论 0原文

这是我的 FB.ui 代码:

FB.ui({ 
  method: 'feed', 
  message: '', 
  link: 'http://mywebaddress/pathToContent', 
  picture: 'http://mywebaddress/pathToPhoto/photo.jpg', 
  display: 'popup'
});

对话框完美弹出,它有链接,所以没问题......但图片不显示。

我已验证图片 URL 正确。然后我使用调试器来测试内容 URL 的开放图标签:它运行完美。

显然,调试器清除了某种缓存。在链接上使用调试器后,FB.ui 对话框可以正常显示图片。

我能做点什么吗?用户从我的网站分享到 Facebook 的内容没有像应有的那样显示图片,这让他们使用起来有点烦人(这从来都不是一件好事!)

谢谢!

Here's my FB.ui code:

FB.ui({ 
  method: 'feed', 
  message: '', 
  link: 'http://mywebaddress/pathToContent', 
  picture: 'http://mywebaddress/pathToPhoto/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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晚风撩人 2024-12-17 00:25:07

您需要更改共享网址源中的 og:imagepicture 参数已弃用:https: //developers.facebook.com/docs/sharing/reference/feed-dialog/#response

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

只等公子 2024-12-17 00:25:07

问题是你没有设置图片的 URL。

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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文