Facebook頁面牆我試圖張貼到使用捲曲我的Facebook頁面牆上,但我不斷收到以下錯誤發佈通過捲曲
The user hasn't authorized the application to perform this action
如何生成使用curl正確的訪問令牌?如果你去這個網址http://developers.facebook.com/tools/explorer/
然後我可以把下面的https://graph.facebook.com/337588736279406/feed,這將顯示出我的牆飼料的話,我可以改變這個發佈和添加一個字段的信息內容,如果我再運行此我得到以下響應。
{
"error": {
"message": "(#200) The user hasn't authorised the application to perform this action",
"type": "OAuthException",
"code": 200
}
}
我必須做什麼來授權我作爲用戶?
有人可以幫助我做到這一點。
<?php
function postify($arr) {
$fields_string = '';
foreach ($arr as $key => $value) {
$fields_string .= $key . '=' . $value . '&';
}
return rtrim($fields_string, '&');
}
$appid = 'app id';
$redirect_url = 'http://stickynote.users36.interdns.co.uk';
$app_secret = 'app secret';
$page_id = '337588736279406';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id='.$appid.'&redirect_uri='.$redirect_url.'&client_secret='.$app_secret.'&perms=publish_stream');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$output = explode("=", $output);
curl_close($ch);
$postdata = array(
'message' => 'this is a test message',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/'.$page_id.'/feed?access_token='.$output[1].'');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, postify($postdata));
$check = curl_exec($ch);
print_r($check);
?>
我該如何做到這一點可以幫助 – DCHP 2012-02-23 16:40:21
我已經發布了我的完整代碼 – DCHP 2012-02-23 16:43:12
嗨多汁感謝回覆我很高興困惑我如何通過捲髮返回訪問令牌我可以運行你說的http:// www。 facebook.com/dialog/oauth/?scope=email,user_birthday,publish_stream&client_id=277938122277013&redirect_uri=http://stickynote.users36.interdns.co.uk&response_type=token這會返回我的url中的代碼,然後我如何訪問這通過curl – DCHP 2012-02-23 16:54:53