2
一個Facebook頁面作爲管理上張貼我不能發佈一個Facebook頁面上的admin.It給了我這個錯誤不能使用圖形API PHP笨
Exception occured, code: 200 with message: (#200) The user hasn't authorized the application to perform this action
雖然我的頁面的管理這裏是我permissions.I覺得我有必要的權限,但仍然是我的代碼不能正常工作
["permissions"]=>
object(stdClass)#41 (1) {
["data"]=>
array(5) {
[0]=>
object(stdClass)#42 (2) {
["permission"]=>
string(12) "user_friends"
["status"]=>
string(7) "granted"
}
[1]=>
object(stdClass)#43 (2) {
["permission"]=>
string(5) "email"
["status"]=>
string(7) "granted"
}
[2]=>
object(stdClass)#44 (2) {
["permission"]=>
string(12) "manage_pages"
["status"]=>
string(7) "granted"
}
[3]=>
object(stdClass)#45 (2) {
["permission"]=>
string(15) "publish_actions"
["status"]=>
string(7) "granted"
}
[4]=>
object(stdClass)#46 (2) {
["permission"]=>
string(14) "public_profile"
["status"]=>
string(7) "granted"
}
}
這裏是我的代碼
if (isset($session)) {
$_SESSION['fb_token'] = $session->getToken();
$session = new FacebookSession($session->getToken());
$request = new FacebookRequest($session, 'GET', '/me?fields=accounts{access_token,category,name,id,perms},permissions');
$response = $request->execute();
$graphObject = $response->getGraphObject()->asArray();
$fb_data = array(
'me' => $graphObject,
'loginUrl' => $helper->getLoginUrl($facebook_default_scope),
);
$this->ci->session->set_userdata('fb_data', $fb_data);
/*Facebook Post*/
try {
$response = (new FacebookRequest(
1420447421611683 is $page_id
$session, 'POST', '/1420447421611683/feed', array(
'access_token' => $fb_data['me']['accounts']->data[0]->access_token,
'link' => 'www.example.com',
'message' => 'Whats Up',
)
))->execute()->getGraphObject();
echo "Posted with id: " . $response->getProperty('id');
} catch(FacebookRequestException $e) {
echo "Exception occured, code: " . $e->getCode();
echo " with message: " . $e->getMessage();
}
/*End*/
}
在此先感謝