facebook open graph meta property og:type of 'website'. The property 'object-name' requires an object of og:type 'object-name'

心已入冬 提交于 2020-01-05 12:08:08

问题


in cake php 1.3 in view ctp i have follow code:

$url = 'http://example.com/exmp/explus/books/view/'.$book['Book']['id'];

echo $this->Html->meta(array('property' => 'fb:app_id', 'content' => '*******'),'',array('inline'=>false));

echo $this->Html->meta(array('property' => 'og:type', 'content' => 'book'),'',array('inline'=>false));

echo $this->Html->meta(array('property' => 'og:url', 'content' => $url ),'',array('inline'=>false));

echo $this->Html->meta(array('property' => 'og:title', 'content' => $book['Book']['title']),'',array('inline'=>false));

echo $this->Html->meta(array('property' => 'og:description', 'content' => $book['Book']['title']),'',array('inline'=>false));

$imgurl = '../image/'.$book['Book']['id'];

echo $this->Html->meta(array('property' => 'og:image', 'content' => $imgurl ),'',array('inline'=>false)); ?>

and it gives the following error when i am posting it'

{
   "error": {
      "message": "(#3502) Object at URL http://example.com/exmp/explus/books/view/234'   has   og:type of 'website'. The property 'book' requires an object of og:type 'book'. ",
      "type": "OAuthException",
      "code": 3502
   }
}

is any one know how to solve it?


回答1:


This issue can occur if your page is restricted for logged in users or has some sort of session logic.

You can use the debug tool from this link :

http://developers.facebook.com/tools/debug

In that link you can give your url (http://example.com/exmp/explus/books/view/234) in the "Input URL, Access Token, or Open Graph Action ID" Field.

After that on clicking the debug button if you are able to see the values for fb:app_id,og:url,og:type,og:title , this issue would not occur.

Else you can check the "URLs" section at the bottom of the page and click the "See exactly what our scraper sees for your URL" link.On clicking the link you can see the html code of your site in the browser. That will help you to debug the issue.




回答2:


BP RAM is right, if you follow his steps you should be able to locate the problem. (I would upvote if I could; not enough reputation.)

I would like share my experience to elaborate. I encountered the same problem recently. Facebook keeps on ignoring all the meta tags and I get the same #3502 error.

I finally used Facebook Debug Tool > "Scraped URL" to inspect my code. This tool shows you exactly what Facebook crawler sees.

I noticed there are php errors mixed in with my HTML code. These errors never appeared in the source code for IE, FF or Chrome. In my case, it was to do with my browser detection code. Facebook's crawler's user_agent was not on my list and caused my detection code to generate error messages which broke the HTML markup. I fixed my function and everything started to work again!

I suggest you check your website with: http://developers.facebook.com/tools/debug/og/echo?q=YOUR_WEBSITE_URL_HERE

(Or use https://developers.facebook.com/tools/debug , type in your URL and press "Scraped URL" at the bottom of the page.)

Check whether there are garbage codes mixed into the <head></head> section. If there is, Facebook will fail to parse the meta tags.



来源:https://stackoverflow.com/questions/10135323/facebook-open-graph-meta-property-ogtype-of-website-the-property-object-nam

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