我使用下面的代碼,以發佈到Facebook頁面,但我得到這個錯誤:(#200)用戶沒有授權應用程序執行此操作facebook php api錯誤?
(#200) The user hasn't authorized the application to perform this action
我得到的manage_page權限對話框,我點擊確定,一切都很好有,所以我不明白爲什麼我不能發佈到Facebook頁面!
這是我的代碼:
<?php
include_once 'inc/facebook.php';
$appId = '000000000000000';
$secret = '00000000000000000000000';
$returnurl = 'https://mrdomain.com';
$permissions = 'manage_pages, publish_stream';
$fb = new Facebook(array('appId'=>$appId, 'secret'=>$secret));
$fbuser = $fb->getUser();
if($fbuser){
if(isset($_POST['msg']) and $_POST['msg']!=''){
try{
$message = array(
'message' => $_POST['msg']
);
$posturl = '/'.$_POST['pageid'].'/feed';
$result = $fb->api($posturl,'POST',$message);
if($result){
echo 'Successfully posted to Facebook Wall...';
}
}catch(FacebookApiException $e){
echo $e->getMessage();
}
}
try{
$qry = 'select page_id, name from page where page_id in (select page_id from page_admin where uid ='.$fbuser.')';
$pages = $fb->api(array('method' => 'fql.query','query' => $qry));
if(empty($pages)){
echo 'The user does not have any pages.';
}else{
echo '<form action="" method="post">';
echo 'Select Page: <select name="pageid">';
foreach($pages as $page){
echo '<option value="'.$page['page_id'].'">'.$page['name'].'</option>';
}
echo '</select>';
echo '<br />Message: <textarea name="msg"></textarea>';
echo '<br /><input type="submit" value="Post to wall" />';
echo '</form>';
}
}catch(FacebookApiException $e){
echo $e->getMessage();
}
}else{
$fbloginurl = $fb->getLoginUrl(array('redirect-uri'=>$returnurl, 'scope'=>$permissions));
echo '<a href="'.$fbloginurl.'">Login with Facebook</a>';
}
?>
做我需要做任何事情之前,我可以張貼到Facebook頁面?
任何幫助,將不勝感激。
的可能重複的[錯誤(#200)的用戶沒有被授權執行該動作的應用](http://stackoverflow.com/questions/24632296/error-200-the-user-hasnt-authorized-該應用程序執行此操作) –