我使用PHP SDK使用facebook::api方法发布到登录用户的时间轴。我很确定我过去让它工作,但现在它似乎失败了,并返回以下错误:
OAuthException:(#3502)URL处的对象http://example.com/具有og:type"网站"的。属性"event"需要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 'Range: bytes=0-40960' -H 'Connection: close' -A 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' $URL_GOES_HERE
我已经将此报告为Facebook的一个错误,目前正处于"分类"阶段。如果我有任何更新,我会在这里发布。