Facebook Open Graph和Metatags

时间:2011-12-12 11:34:31

标签: facebook meta-tags facebook-opengraph

我在https://developers.facebook.com/tools/debug

处有以下输出

我添加了locale元标记,因为我有很多无关的属性错误。但这并没有解决它。

Extraneous Property: Objects of this type do not allow properties named og:latitude
Extraneous Property: Objects of this type do not allow properties named og:longitude.
Extraneous Property: Objects of this type do not allow properties named og:region.
Extraneous Property: Objects of this type do not allow properties named og:street-address.
Extraneous Property: Objects of this type do not allow properties named og:locality.
Extraneous Property: Objects of this type do not allow properties named og:postal-code.
Extraneous Property: Objects of this type do not allow properties named og:country-name.
Extraneous Property: Objects of this type do not allow properties named og:email.
Extraneous Property: Objects of this type do not allow properties named og:phone_number.
Extraneous Property: Objects of this type do not allow properties named og:fax_number.

我在<html>标记中也有名称空间:

<html 
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:og="http://ogp.me/ns#" 
    xmlns:fb="http://ogp.me/ns/fb#">

我也试过xmlns:fb="https://www.facebook.com/2008/fbml" 如下所示:https://developers.facebook.com/docs/opengraph/

我的doctype是<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

我已检查此帖子Facebook Open Graph locale for Australia和此Object Debugger gives me Extraneous Property And Inferred Property error on opg

但我仍然有无关的属性错误

编辑:我使用了这个文档:https://developers.facebook.com/docs/opengraph/#extra-data当我浏览开放图的命名空间定义时,我看不到纬度和经度选项,但Facebook的文档确实推荐它。但Facebook的调试人员不接受它。我在这里错过了一些东西......

编辑2:我有:

<meta property="og:type" content="company" />

但Facebook说:https://graph.facebook.com/10150616664862786

输入:网站 ???

为什么Facebook会看到不同的类型?我该如何解决这个问题?

3 个答案:

答案 0 :(得分:1)

这是因为即使您指定了og:type = company,linter也会显示您的类型是网站,并且您尝试使用的属性不适用于网站对象类型。这个here有一个公认的答案。你真正的问题是linter正在读取og:输入错误。

答案 1 :(得分:1)

Facebook的文档已经过时了(令人大吃一惊。)唯一允许的og:类型可以找到here,其中没有一个是公司。

答案 2 :(得分:0)

您还应该记住将namespace declaration添加到页面的head和body标签中。

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xmlns:fb="https://www.facebook.com/2008/fbml"> 
   <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns# YOUR_NAMESPACE: http://ogp.me/ns/apps/YOUR_NAMESPACE#"> 
     <meta property="fb:app_id" content="YOUR_APP_ID" /> 
     <meta ...

显然,请使用您应用的设置替换YOUR_NAMESPACEYOUR_APP_ID