我正在使用 PHP SDK 通过 facebook::api 方法发布到登录用户时间线。我很确定我过去让它工作,但现在它似乎失败并返回以下错误:
OAuthException: (#3502) Object at URL http://example.com/ has og:type of 'website'. The property 'event' requires an object of og:type 'example:event'.
我已将 URL 放入 Facebook 调试器工具中,并且返回正常。我还使用了 Graph API 资源管理器来测试 POST 请求,这很有效。唯一没有的地方是我的 PHP 脚本。
我知道我不是唯一遇到这种情况的人,但似乎其他人都在使用 Javascript SDK,因此该解决方案与我无关。
我也曾尝试在我的请求中设置 scrape=true
但这没有任何区别。
我使用的代码是:
try{
// Post the reply to the Facebook users wall
$this->facebook_get_attendance['action_id'] = $this->facebook->api(
"/me/example:reply?event=".urlencode("http://www.example.com/facebook-event/$this->area_rel/$this->facebook_event_reply_id")."&scrape=true&access_token={$this->facebook_user_details['access_token']}",
"POST"
);
$this->facebook_get_attendance['action_id'] = $this->facebook_get_attendance['action_id']['id'];
}catch(FacebookApiException $e){
error_log($e);
$this->facebook_get_attendance['action_id'] = NULL;
}
知道为什么会这样吗?
传递的 URL 是:
/me/example:reply?event=http%3A%2F%2Fwww.example.com%2Ffacebook-event%2Fbath%2F612&access_token=ACCESS_TOKEN
最佳答案
基于以往经验的最可能的解释:
- 您在事件页面上有一个 og:url 标签,它将 facebook 重定向到其他没有事件 OG 标签的地方
- 您的站点向爬虫返回的内容与它返回给普通用户的内容不同(例如站点是否需要登录)- 使用手动请求进行调试:
curl -i -H 'Accept: */* ' -H '范围:字节=0-40960' -H '连接:关闭' -A 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' $URL_GOES_HERE
<
关于php - 发布到时间轴未正确抓取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9354596/