Facebook 开放图元标签和有效的 HTML
可能的重复:
属性属性的 HTML 验证错误
根据 facebook 使用他们的 Like 按钮和打开图形元标记,您需要将类似的内容放入您的 html 页面中。
<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>
他们到底在玩什么把戏?这是无效的 html,属性“property”不是也从来不是元标记的属性,那么到底为什么 facebook 使用它而不是
;?我不愿意在我的网站上尝试使用有效的“名称”而不是“属性”,因为如果我尝试了,但它在我的网站上不起作用,那么任何在我测试它时点击“喜欢”的人都会失败。那么...有谁知道如果我使用“名称”而不是“属性”,这仍然有效吗?
Possible Duplicate:
Html validation error for property attribute
According to facebook to use their like button and the open graph meta tags you need to place something like this into your html page.
<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>
What the hell are they playing at? This is invalid html, the attribute 'property' is not and never has been an attribute of the meta tag so why on earth have facebook used this instead of <meta name="og:title" content="The Rock" />?
I am reluctant to try on my site live with valid 'name' instead of 'property' because if I do try and it doesn't work on my site then anyone who clicks like while i am testing it out will have their like fail. So ... Does anyone know if I use the use 'name' instead of 'property' will this still work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要忘记,他们还希望您向 html 标签声明一些模式 - 特别是通过
xmlns:og="http://opengraphprotocol.org/schema/
声明开放图模式。OG 是基于 将附加属性添加到元标记中。完成后, 请务必添加您的 fb:like -
- 示例非常简单,不要忘记添加xmlns:fb="http。 ://www.facebook.com/2008/fbml"
否则你会很难过发现这个答案关于元标记的验证。执行该答案所描述的操作应该可以让您通过任何 w3c 验证器。
Don't forget that they also want you to declare some schemas to the html tag - specifically the open graph one via
xmlns:og="http://opengraphprotocol.org/schema/
. OG is based on RDFa which adds the additional attributes to the meta tags.Once you're done with that, be sure to add your fb:like -
<fb:like href="http://developers.facebook.com/" width="450" height="80"/>
- the example is pretty straightforward. Don't forget to addxmlns:fb="http://www.facebook.com/2008/fbml"
otherwise you will be sadFound this answer on SO regarding validation of the meta tag. Doing what that answer describes should give let you pass it through any w3c validator.