Facebook OAuthException:验证应用程序时出错
问题描述:
我有一个简单的PHP页面,用于将消息发布到我自己的墙上。Facebook OAuthException:验证应用程序时出错
我已经获得了具有“read_stream”和“publish_stream”权限的offline_access标记。
define('FB_APIKEY', 'MY_APP_KEY');
define('FB_SECRET', 'MY_APP_SECRET');
define('FB_SESSION', 'MY_OFFLINE_TOKEN');
require_once('facebook.php');
try {
$facebook = new Facebook(FB_APIKEY, FB_SECRET);
$facebook->api_client->session_key = FB_SESSION;
$attachment = array(
'message' => 'some meesgae',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'mylink.com',
'description' => 'this is a description',
'actions' => array(array(
'name' => 'Get Search',
'link' => 'google.com'
))
);
$result = $facebook->api('/me/feed?access_token=' . FB_SESSION,
'post',
$attachment);
var_dump($result);
} catch(Exception $e) {
echo $e;
}
当我运行这个,我得到“OAuthException:错误验证应用程序”。
我确认我的离线令牌是好的。当我转到https://graph.facebook.com/me?access_token=[MY_OFFLINE_TOKEN]时,它会以JSON格式正确返回我的公开个人档案。
所以,我在想我在某个地方的API调用中出现了错误,但对于我来说,我似乎无法弄清楚。在过去的两天里,我一直在解决这个问题。有人可以请帮忙! :(
答
你不必APP ID这里并作出这样的电话:。
require_once('facebook.php');
$facebook = new Facebook(array(
'appId' => 'APP_ID',
'secret' => 'APP_SECRET',
'cookie' => true
));
try {
$attachment = array(
'message' => 'some meesgae',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'mylink.com',
'description' => 'this is a description',
'actions' => array(array(
'name' => 'Get Search',
'link' => 'google.com'
))
);
$attachment['access_token'] = $offline_access_token; // add it to the array
$result = $facebook->api('/me/feed', 'POST', $attachment);
var_dump($result);
} catch(Exception $e) {
// error_log($e); // should use something like this when in production
echo $e;
}
未经检验的,但应该工作让我知道,如果它不
这工作就像一个魅力。谢谢,谢谢,谢谢!!!! – PFrank 2011-05-13 13:23:19
你知道如何以页面的名义发布? – opHASnoNAME 2012-01-14 06:52:34