php - FB 开放图谱 OAuthException : (#3502) og:type is website and not namespace:object

标签 php facebook-opengraph

我正在尝试使用 og 向我的网站添加自定义操作和对象。正如我在之前搜索过的问题中所述,调试器正确地抓取了网站并确认这是他们应有的方式,没有任何错误、警告或异常。

但是,当我使用 php sdk 发布到该对象时,我从 FB 收到此异常:

OAuthException: (#3502) Object at URL //mypage.com/image/details has og:type of 'website'. The property 'photo' requires an object of og:type 'app_prod:photo'.

[注意我已经删除了所有“http://”以便 stackoverflow 不会将它们呈现为链接]

php sdk调用:

$ret_obj = $facebook->api('/me/app_prod:love', 'POST', array(
'photo' => '//mypage.com/image/details',
'access_token' => $token ));

页面的头部是这样的:

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

<meta property="fb:app_id" content="APP_ID">
<meta property="og:type" content="app_prod:photo">
<meta property="og:url" content="http://mypage.com/image/details">
<meta property="og:title" content="A Picture I love">
<meta property="og:image" content="http://images.mypage.com/8f9117301e00dbfb.jpg">
<meta property="og:description" content="Here is a description">

我已经仔细检查过的事情:

  1. 我有正确的应用程序 ID。

  2. 当我使用 facebook 提供的 curl 命令进行操作时,它发布正常。

  3. 我的 head 和 meta 标签正是我从 facebook 提供的对象“代码”中复制的内容。

提前致谢!

最佳答案

我找到了解决方案 here在 Stackoverflow 上 here .

The problem is usually caused by a server race condition – the application’s inability to handle two simultaneous HTTP requests. Sometimes when a user performs an action and the application calls a FB open graph request right away, chances are the new object page hasn’t been generated yet.

var openGraphUrl = '/me/' + OG_NAMESPACE + ':' + OG_ACTION + '?' + OG_OBJECT + '=' + siteURL;
var scrapeUrl    = '/?ids='+siteURL+'&scrape=true';
_.setTimeout(function(){
  FB.api(scrapeUrl, 'post',
    function(response) {
      if (!response || response.error) {
        console.log('scrap: '+response.error.message);
      } else {
        FB.api(openGraphUrl, 'post',
          function(response) {
        if (!response || response.error) {
          console.log('OG: '+response.error.message);
        } else {
          console.log('Successful! Action ID: ' + response.id);
            }
          }
        );
      }
    });
}
, 5000);

关于php - FB 开放图谱 OAuthException : (#3502) og:type is website and not namespace:object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11889493/

相关文章:

php - Laravel 和远程挂载点 (sshfs)

php - 无法使用php将数据从android插入到mysql

php - 使用 mysql DB 中的 DOB 来确定 child /成人

php - 如何从 SQL 查询 php 获取值并将其存储到变量中

PHP Respect Relational - 从特定列更新

facebook - 如何一对一发布开放图故事 - 没有对象标题?

facebook-opengraph - 如何使用 'og'(开放图谱)元标记进行 Facebook 共享

facebook-opengraph - 打开图 : List of global types

facebook - 打开图 : custom properties not showing in post

ios - 用户是否需要登录 Facebook 才能通过 Facebook Messenger 分享开放图谱故事?