理解真实示例开放图协议

understanding of real example open graph protocol

在 open graph 主页上显示以下内容: 例如,以下是 The Rock

的 Open Graph 协议标记
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>

现在某些服务,如 twitter 和 facebook,可以在链接到 url?也试图使术语正确。网页中 og 标记的开放服务 (edu) 的任何链接及其在其他站点上的使用表示赞赏。

OG 协议仅适用于 Facebook,不适用于 Twitter,后者需要自己的 Twitter 卡片标签。

对于 Facebook,您的标签必须完整,就像这个块:

<meta property="fb:app_id" content="ENTER YOUR APP ID"/>
<meta property="fb:admins" content="ENTER YOUR PERSONAL ID"/>
<meta property="og:site_name" content="ENTER SITE NAME" />
<meta property="og:type" content="website" />
<meta property="og:title" content="ENTER SITE TITLE"/>
<meta property="og:description" content="ENTER SITE DESCRIPTION"/>
<meta property="og:url" content="ENTER SITE URL" />
<meta property="og:image" content="ENTER IMG URL" />
<meta property="og:image:type" content="image/png" /> <!-- enter IMG extension -->
<meta property="og:image:width" content="1200" /> <!-- enter IMG width, in px -->
<meta property="og:image:height" content="630" /> <!-- enter IMG height, in px -->

Facebook 大卡片的图片应为 1200 像素 x 630 像素,小图片应为 600 x 315 像素,以便它们完全适合屏幕。你可以查看一下here.

对于 facebook,也建议您将此添加到 <head>:

<head prefix="og: http://ogp.me/ns#>

在这里您会找到 OG 协议的 guide for best practices when sharing website content on Facebook. Here you'll find a full guide for OG Protocol and here you can find the Facebook Debugger Tool

现在,对于 Twitter,您必须添加自己的标签,例如:

<meta name="twitter:card" content="summary_large_image"> <!-- there are other card types you can choose --> 
<meta name="twitter:site" content="@YOUR_USERNAME">
<meta name="twitter:creator" content="@YOUR_USERNAME"> <!-- or author's name, if that is the case -->
<meta name="twitter:title" content="ENTER THE WEBSITE TITLE">
<meta name="twitter:description" content="ENTER THE WEBSITE DESCRIPTION">
<meta name="twitter:image" content="ENTER THE IMG URL"> 

您可以找到所有 Twitter 卡片文档 here and the testing tool here

您可以在此 blog (Facebook & Twitter) and in this site(仅限 Facebook)中查看工作示例。

最后,要了解这些东西的确切作用,请分享我为您提供的链接的这些网站,您将看到 post 的分享在 Facebook 上的样子。如果您不想公开分享,请限制 post 仅供您自己使用,这样您就无需向您的朋友解释为什么要分享这些内容!对于 Twitter,您可以查看 my own feed,这样您会在那里看到一些卡片。

希望对您有所帮助!