OAutheException在使用PHP发布到FaceBook墙时?
我试图使用PHP在FaceBook墙上发布帖子,但出现错误:OAutheException在使用PHP发布到FaceBook墙时?,facebook,debugging,facebook-graph-api,facebook-wall,Facebook,Debugging,Facebook Graph Api,Facebook Wall,我试图使用PHP在FaceBook墙上发布帖子,但出现错误: Uncaught OAuthException: (#200) The user hasn't authorized the application to perform this action thrown in /hermes/web09/b924/moo.freecostwebscom2/picslanda/fbpic/library/base_facebook.php on line 1106" 使用以下客户端代码: $ap
Uncaught OAuthException: (#200) The user hasn't authorized the application to perform this action thrown in /hermes/web09/b924/moo.freecostwebscom2/picslanda/fbpic/library/base_facebook.php on line 1106"
使用以下客户端代码:
$app_id = "257711244318488";
$app_secret = "dc4b279079e4eaff6e5b9ef37fb48402";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$fbcheck= $facebook->getUser();
if(is_null($fbcheck) or !$fbcheck or $fbcheck==0)
{
header("Location:{$facebook->getLoginUrl(array('scope' => 'user_status,publish_stream,user_photos'))}");
exit;
}
if($_SERVER['REQUEST_METHOD'] =='POST'){
//$img = realpath($_FILES["pic"]["tmp_name"]);
$facebook->setFileUploadSupport("http://" . $_SERVER['SERVER_NAME']);
$photo = $facebook->api('/me/photos', 'POST',
array(
'source' => $urlParser->fbpostpic($input['ik']),
'message' => 'This photo was uploaded via www.Picslanda.com'
)
);
echo '<p><a target="_blank" href="http://www.facebook.com/photo.php?fbid='.$photo['id'].'">Click here to watch this photo on Facebook.</a></p>';
}
$attachment = array(
'message' => 'Hello friends ',
'name' => "My Name",
'caption' => "My caption",
'link' => "www.site.com",
'description' => 'Description.',
'picture' => "url",
'actions' => array(array(
'name' => 'Get Search',
'link' => 'http://www.google.com'
))
);
$result = $facebook->api(
'/me/feed/',
'post',
$attachment
);
$app_id=“257711244318488”;
$app_secret=“dc4b279079e4eaff6e5b9ef37fb48402”;
$facebook=新的facebook(数组)(
“appId”=>$app\u id,
'secret'=>$app\u secret,
“cookie”=>true
));
$fbcheck=$facebook->getUser();
如果(为null($fbcheck)或!$fbcheck或$fbcheck==0)
{
标题(“位置:{$facebook->getLoginUrl(数组('scope'=>'user\u status,publish\u stream,user\u photos'))));
出口
}
如果($\u服务器['REQUEST\u METHOD']='POST'){
//$img=realpath($_文件[“pic”][“tmp_名称]);
$facebook->setFileUploadSupport(“http://”$\u SERVER['SERVER\u NAME']);
$photo=$facebook->api('/me/photos',POST',
排列(
'source'=>$urlParser->FBPOSTIC($input['ik']),
“消息”=>“这张照片是通过www.Picslanda.com上传的”
)
);
回声“”;
}
$attachment=array(
'message'=>'Hello friends',
“姓名”=>“我的姓名”,
“标题”=>“我的标题”,
“链接”=>“www.site.com”,
“说明”=>“说明”,
'图片'=>“url”,
“操作”=>数组(数组(
'名称'=>'获取搜索',
'链接'=>'http://www.google.com'
))
);
$result=$facebook->api(
“/me/feed/”,
"岗位",,
$attachment
);
我的代码中是否存在任何可能导致此问题的可见错误?
如何调试此错误?在PHP SDK v.3.x.x中,“req\u perms”更改为“scope” 所以不是
header("Location:{$facebook->getLoginUrl(array('req_perms' => 'user_status,publish_stream,user_photos,offline_access'))}");
试一试
在上传带有
fb api的图像之前将其放入
$facebook->setFileUploadSupport(true);
谢谢你的重播。现在我可以贴到墙上了,但我正试图上传一张图片到Facebook上。“致命错误:未捕获OAutheException:(#324)需要抛出上载文件”这是我现在遇到的错误。
$facebook->setFileUploadSupport(true);