我正在學習Facebook應用程序開發,我希望我的應用程序在用戶的牆上張貼簡單的消息。使用Graph API在牆上發佈消息?
我該如何使用圖API來做到這一點?
我正在使用servlets開發應用程序。
我正在學習Facebook應用程序開發,我希望我的應用程序在用戶的牆上張貼簡單的消息。使用Graph API在牆上發佈消息?
我該如何使用圖API來做到這一點?
我正在使用servlets開發應用程序。
首先,您需要使用'https://graph.facebook.com/oauth/'獲取用戶的access_token(登錄後)。
https://developers.facebook.com/docs/authentication/
注意,他會的access_token由$ REQUEST [ '代碼'],你必須在這UNCODE被檢索到自己的PHP或whatelse 「& REDIRECT_URI = WWW.YOUR_WEB.PHP」方法:
$code = $_REQUEST['code'];
$url = "https://graph.facebook.com/oauth/access_token?";
$url .= "client_id=" . $APP_ID;
$url .= "&client_secret=" . $APP_SECRET;
$url .= "&code=" . $code;
$url .= "&redirect_uri=" . $MY_URL;
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $url);
$response = curl_exec($c);
curl_close($c);
$response = explode("&", $response);
foreach($response as $key => $value)
{
$pair = explode("=", $value);
$response[$pair[0]] = $pair[1];
unset($response[$key]);
}
$access_token = $response['access_token'];
$expires = $response['expires'];
後來張貼在你需要調用這樣一個URL牆:
_url = "https://graph.facebook.com/" + user_id + "/feed?message=MSG_STRING"
_url += "&access_token=" + access_token;
_url += "&name=NAME_STRING";
_url += "&link=LINK_URL";
_url += "&description=DESCRIPTION_STRING";
_url += "&method=post";
您可以使用socialauth庫在FB牆上發佈消息。
http://code.google.com/p/socialauth/
如何張貼在朋友的牆上的消息,請訪問一個以下鏈接: -
http://code.google.com/p/socialauth/issues/detail?id=233。
我希望使用java servlets不是PHP – arpitsolanki