Facebook、Twitter、LinkedIn分享按钮总结

社交媒体分享机制解析
本文介绍了如何通过使用Open Graph协议及特定平台的元标签来优化Facebook、Twitter和LinkedIn上的内容分享体验。文章详细解释了不同平台支持的元标签类型及其正确用法,并提供了调试工具链接。

Facebook、Twitter、LinkedIn都有分享按钮组件,可以通过点击按钮分享当前页面。

点击按钮后社交平台会得到当前页面的URL,然后会调用爬虫来抓取这个URL的信息,

这里有两种情况:

  • 使用了Open Graph标签

    Facebook以及LinkedIn一般使用如下meta标签
    <meta property="og:title" content="My Shared Article Title" />
      <meta property="og:description" content="Description of shared article" />
      <meta property="og:url" content="http://example.com/my_article.html" />
      <meta property="og:image" content="http://example.com/foo.jpg" />
    Twitter可以使用og标签也可以使用Twitter自定义的标签,一般如下:
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:site" content="@flickr" />
    <meta name="twitter:title" content="Small Island Developing States Photo Submission" />
    <meta name="twitter:description" content="View the album on Flickr." />
    <meta name="twitter:image" content="https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg" />
    也可以使用如下标签
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:site" content="@nytimesbits" />
    <meta name="twitter:creator" content="@nickbilton" />
    <meta property="og:url" content="http://bits.blogs.nytimes.com/2011/12/08/a-twitter-for-my-sister/" />
    <meta property="og:title" content="A Twitter for My Sister" />
    <meta property="og:description" content="In the early days, Twitter grew so quickly that it was almost impossible to add new features because engineers spent their time trying to keep the rocket ship from stalling." />
    <meta property="og:image" content="http://graphics8.nytimes.com/images/2011/12/08/technology/bits-newtwitter/bits-newtwitter-tmagArticle.jpg" />

    需要注意的地方:
    1、对于Facebook以及LinkedIn,og:image标签的url可以不带协议头,但Twitter必须携带协议头,否则会出现取不到图片的情况。
    2、对于Twitter不论使用以上哪种标签方式twitter:card是必须的,值有两种summarysummary_large_image,展示效果如下,我也很奇怪为什么summary_large_image的图那么小
    3、社交平台抓取到图片后需要将图片转存到他们自己的服务器上,然后才会在分享时出现,所以可能会出现某个链接首次分享时没有图片的情况


    具体可以参考文档
    Facebook:https://developers.facebook.com/docs/sharing/webmasters#markup
    LinkedIn:https://developer.linkedin.com/docs/share-on-linkedin
    Twitter:https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/abouts-cards
    三个平台分别提供了链接测试工具,可以通过测试工具来检测分享效果
    Facebook:https://developers.facebook.com/tools/debug/
    LinkedIn:https://www.linkedin.com/post-inspector/
    Twitter:https://cards-dev.twitter.com/validator
  • 不使用Open Grahp标签
    当不使用标签时,社交平台会按代码从上往下的顺序去抓取img标签,注意是代码顺序,不是页面展示顺序,还会抓取页面的TKD(title、keyword、description)标签用于分享内容

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值