如何为我的订阅源获取Facebook用户access_token
问题描述:
我正在使用jQuery来处理来自我的Facebook墙的json数据。呼叫我的JSON文件是这样的:如何为我的订阅源获取Facebook用户access_token
var url = 'http://graph.facebook.com/myname/feed'; $.getJSON(url+'&callback=?',function(json){...});
自6月4日。我收到了Facebook消息,需要用户access_token。但在哪里/我如何获得这个令牌?如果我想长时间使用这个令牌,我该怎么办?
答
我有同样的问题,并提出用“门” PHP这样的外观图释:
// Settings
$FBid = 'YOUR PAGE ID'; //Page name or Page ID
$app_id = 'YOUR APP ID';
$app_secret = 'YOUR APP SECRET';
$url_get_access_token = 'https://graph.facebook.com/oauth/access_token';
$url_params = "?type=client_cred&client_id=".$app_id."&client_secret=".$app_secret;
$access_token = file_get_contents($url_get_access_token . $url_params);
//Get the contents of a Facebook page
$dataType = 'posts'; // it could be replaced by feed, etc.
$url_fb_data = "https://graph.facebook.com/".$FBid."/".$dataType."?".$access_token;
$FBpage = file_get_contents($url_fb_data);
//Convert data into a php object format
//$FBdata = json_decode($FBpage);
//Print data in JSON format
echo $FBpage;
有了这个脚本,所有你所要做的就是调用改变这个,而不是https://graph.facebook.com/ ... ...
我希望这可以帮助你,它为我工作。
显示错误的请求 – 2011-12-16 08:45:43