我应该如何构建代码以便 Facebook 和 Google+当有人共享 URL 时获取正确的元素?
我想知道当用户在 Facebook 或 Google+ 上共享网址时会获取哪些元素... 例如:我如何确保帖子的描述将是我想要共享的描述并且图像将是我想要共享的图像? 标题很明显,所以我跳过了。
I was wondering which elements are fetched when an user shares an url on Facebook or Google+...
For example: how can i make sure the description of the post will be the description i want to be shared and the image will be the image i want to be shared?
Title is pretty obvious, so i skipped that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Facebook 建议使用 opengraph 协议:http://ogp.me
它工作可靠,可以使用 facebook url linter 检查 http://developers.facebook.com/tools/lint/
Facebook suggests the opengraph protocol: http://ogp.me
It works reliable and can be checked with the facebook url linter http://developers.facebook.com/tools/lint/
有趣的是,我刚刚写了一篇关于这周。在我看来,没有可靠的方法可以知道社交网站将如何解析您的网页以获取其“状态”版本。不仅每个网站的做法不同(即 FB、linkedin 和 G+),而且他们很可能会随心所欲地更改它。
所以目前简短的答案是你无法确定这一点。您必须对每个社交网站的行为进行逆向工程,并希望它不会经常改变。直到行业变得聪明并决定使用一些标记来传达,例如,页面上的哪个图像被认为是主要的“共享”图像,等等。
Funny, I just wrote a blog post about this this week. It seems to me that there's no reliable way of knowing how either social network site will parse your web page to get the "status" version of it. Not only does each site do it differently (i.e. FB, vs. linkedin vs. G+), but they're liable to change it at a whim.
So currently the short answer is that you can't know this for sure. You have to reverse engineer each social network site's behavior and hope it doesn't change too often. That is until the industry smartens up and decides on some markup to convey, for example, which image form a page is considered the cardinal "share" image, and so on.