[英]Post in a message on the wall using Graph API?
我正在学习Facebook应用程序开发,希望我的应用程序在用户墙上发布一条简单的消息。
如何使用图表API?
我正在使用servlet开发应用程序。
首先,您需要使用“ https://graph.facebook.com/oauth/”获取用户的access_token(登录后)。
https://developers.facebook.com/docs/authentication/
注意,他的access_token将通过$ REQUEST ['code']检索到您自己的php或其他“&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 = "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 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.