Facebook Open Graph and Metatags

荒凉一梦 提交于 2019-11-28 02:16:21

问题


I have the following output at https://developers.facebook.com/tools/debug

I added the locale metatag, because I had a lot of Extraneous Property errors. But that does not solve it.

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.

I also have the namespaces in the <html> tag:

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

I have also tried xmlns:fb="https://www.facebook.com/2008/fbml" as suggested here: https://developers.facebook.com/docs/opengraph/

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

I have checked this thread Facebook Open Graph locale for Australia and this Object Debugger gives me Extraneous Property And Inferred Property error on opg

But I still have the Extraneous Property error

Edit: I used this documentation: https://developers.facebook.com/docs/opengraph/#extra-data When I browse to the namespace definition of open graph, I don't see the latitude and longtitude options, but Facebook's documentation does recommend it. But the debugger of Facebook does not accepts it. I am missing something here...

Edit2: I have:

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

but Facebook says: https://graph.facebook.com/10150616664862786

type: website ???

Why does Facebook see a different type? And how do I fix this?


回答1:


This is because even though you have specified og:type=company, the linter is showing that your type is website, and the properties you are trying to use are not applicable for a website object type. There is an accepted answer for this here. Your real problem is that the linter is reading og:type incorrectly.




回答2:


Facebook's documentation is out of date, (big surprise there.) The only allowed og:types can be found here, none of which are company.




回答3:


You should also remember to add namespace declaration to the head and body tags of your page.

<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 ...

Obviously, replace YOUR_NAMESPACE and YOUR_APP_ID with your app's settings.



来源:https://stackoverflow.com/questions/8473657/facebook-open-graph-and-metatags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!