5 일 간의 시행 착오 후 나는 내가하고 싶은 일에 매우 가깝게 접근하고 있습니다.(# 200) 사용자가이 페이지에서이 작업을 수행 할 수있는 관리 권한이 충분하지 않습니다.
한 가지 예외가 있습니다. 내 현재 코드는 한 번만 작동합니다. 여기
는 시나리오나는 페이스 북 SDK를 사용하여 페이스 북 페이지로 Add A Page Tab
에 노력하고 있습니다.
내 현재 코드는 방식으로 작동하지만 그것은 단지 페이스 북에서 만든 최초의 페이스 북 페이지에 대해 작동하며 내가 다른 페이지의 페이지 탭을 추가하려고하면, 그것은 다음과 같은 오류가 발생합니다 :
(#200) User does not have sufficient administrative permission for this action on this page
을
왜 이런 일이 발생하는지 이해가되지 않습니다. 이 오류는 일반적으로 페이지 액세스 토큰이 없다는 것을 의미하지만, 그렇다면 내 코드가 첫 페이지에도 작동하지 않아야합니다.
누군가 내가 현재 잘못하고있는 부분을보기 위해 내 현재 코드를 살펴볼 수 있습니까?
어떤 도움을 주시면 감사하겠습니다.
이 토큰도 양식 제출 후 액세스를 얻을 수있는 부분이다 :
내 현재 코드는 다음과 같이
// Set Extended Access Token
if (isset($code)) {
$fb->setExtendedAccessToken();
//Get access short live access token
$accessToken = $fb->getAccessToken();
// Exchange token
$fb->api('/oauth/access_token', 'POST',
array(
'grant_type' => 'fb_exchange_token',
'client_id' => $appId ,
'client_secret' => $secret,
'fb_exchange_token' => $accessToken
)
);
$token_url="https://graph.facebook.com/oauth/access_token?client_id=" . $appId
. "&client_secret=" . $secret
. "&code=" . $code
. "&redirect_uri=" . $returnurl;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$user_access_token = $params['access_token'];
$attachment_1 = array(
'access_token' => $user_access_token
);
}
$result = $fb->api("/me/accounts", $attachment_1);
foreach($result["data"] as $page) {
if($page["page_id"] == $page_id) {
$page_access_token = $page["access_token"];
//echo $page_access_token;
break;
}
}
//$pageIds=$fb->api('/me/accounts');
//$pageAccessToken=$pageIds["data"][1]["access_token"];
if(isset($_POST['msg']) and $_POST['msg']!=''){
try{
$message = array(
'access_token' => $page_access_token,
'message' => $_POST['msg']
);
$posturl = '/'.$_POST['pageid'].'/feed';
$posturl2 = '/'.$_POST['pageid'].'/tabs';
$fb->api($posturl2, 'POST', array(
'app_id'=>'0000000000000000000000000',
'access_token'=>$page_access_token
));
$result = $fb->api($posturl,'POST', $message);
if($result){
echo 'Successfully posted to Facebook Wall...';
}
}catch(FacebookApiException $e){
echo $e->getMessage();
}
}
나는 내 형태로 사용자의 페이지를 채우는 방법이 내 페이지 :
if(empty($pages)){
echo 'The user does not have any pages.';
}else{
echo '<form action="" method="post">';
echo 'Select Page: <select name="pageid">';
echo '<option value="">Select A Page</option>';
foreach($pages as $page){
echo '<option value="'.$page['page_id'].'">'.$page['name'].'</option>';
}
echo '</select>';
//echo 'Select Page: <select name="pageid2">';
// foreach($pageIds as $pageId){
// echo '<option value="'.$page['page_id'].'">'.$pageAccessToken.'</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();
}
@SahilMittal이 코드가 없으면 내 스크립트가 어떻게 작동하는지 알 수 없으므로 다른 사람이 "충분한 코드를 게시하지 않은 이유"를 알 수 있습니다! 또한 이것은 많은 코드가 아닙니다. 그것의 단지 몇 라인. 어쨌든 대부분 주석은 코드입니다. – user3806613