我需要張貼到我自己的牆壁前進行身份驗證,所以這裏是我的代碼認證Facebook應用程序 - PHP
function get_app_token($appid, $appsecret)
{
$args = array(
'grant_type' => 'client_credentials',
'client_id' => $appid,
'client_secret' => $appsecret
);
$ch = curl_init();
$url = 'https://graph.facebook.com/oauth/access_token';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
return json_encode($data);
}
$token = get_app_token($appid, $appsecret);
$attachment = array('message' => '',
'access_token' => $token,
'name' => 'Attachment Name',
'caption' => 'Attachment Caption',
'link' => 'http://apps.facebook.com/xxxxxx/',
'description' => 'Description .....',
'picture' => 'http://www.google.com/logo.jpg',
'actions' => array(array('name' => 'Action Text',
'link' => 'http://apps.facebook.com/xxxxxx/'))
);
$result = $facebook->api('/me/feed/', 'post', $attachment);
我得到錯誤OAuthException ,無效的OAuth訪問令牌簽名。
的[需要對張貼在牆上用戶幫助]可能重複(http://stackoverflow.com/questions/5126665/need-幫助發佈在用戶牆上) – ifaour 2011-04-08 11:20:58
我上面發佈的鏈接將幫助您入門。您正在申請一個「應用程序訪問令牌」!這不是用來代表用戶完成任務的! – ifaour 2011-04-08 11:21:53