开放图协议。如何检测是否是Facebook
在 LinkedIn 上此处“图像必须至少为 80 x 150 像素”。在 Facebook 上此处图片“不能超过 130x110 像素”。我想使用 php 函数来调整 Facebook 或 LinkedIn 的缩略图大小。
分享链接时如何检测是 Facebook 还是 LinkedIn?
编辑(详细信息):
当我粘贴链接以在 Facebook 或 LinkedIn 中共享它时,他们会获取 html 文档头部内这些标签中的信息:
<meta property="og:url" content="..." />
<meta property="og:description" content="..." />
<meta property="og:image" content="image.jpg" />
<meta property="og:title" content="title" />
<meta property="og:type" content="website" />
<meta property="fb:app_id" content="id..." />
<meta property="og:locale" content="en_US" />
对于 LinkedIn 的 og:image 部分,如果小于提到的尺寸会忽略它,而对于 Facebook 来说,所需的最大值比 LinkedIn 想要的要小,而在 Facebook 上,对于错误的图片,它会默认显示自己的图像。所以我试图检测我是否在 Facebook 或 LinkedIn 上共享链接以调整适当的大小
On LinkedIn here "image must be at least 80 x 150 pixels". On Facebook here image "cannot exceed 130x110 pixels". I want to use a php function to resize a thumbnail for Facebook or LinkedIn.
How can I detect if is Facebook or LinkedIn when I share a link?
EDIT(Details):
When I paste a link to share it in Facebook or LinkedIn, they get the info that is in these tags inside the head of a html document:
<meta property="og:url" content="..." />
<meta property="og:description" content="..." />
<meta property="og:image" content="image.jpg" />
<meta property="og:title" content="title" />
<meta property="og:type" content="website" />
<meta property="fb:app_id" content="id..." />
<meta property="og:locale" content="en_US" />
For the og:image part for LinkedIn if is smaller then dimensions mentioned it will ignore it, while for Facebook the maximum required is smaller then what LinkedIn wants, and on Facebook for a wrong picture it looks to display a image of their own by default. So I'm trying to detect if I share a link on Facebook or LinkedIn to resize appropriate
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查找请求的用户代理,如果是 Facebook,则提供 Facebook 优化图像,否则提供默认图像(linkedin 大小)。
资料来源:开放图谱协议,最佳实践部分。
注意:虽然这不是此用户代理的目的(不清楚什么是允许和不允许)。但我认为您的目的不会违反任何平台政策。
Look for the user agent of the request, if it's Facebook then serve the Facebook optimized image otherwise the default one (linkedin sizes).
Source: Open Graph Protocol, Best Practices section.
NOTE: While this is not the purpose of this user agent (it's not clear what is allowed and not allowed). But I think your purpose won't violate any platform policies.