开发者

How do I get the facebook user access_token for my feed

I am using jQuery to work with a json-data from my Facebook wall. The call for my json-file is like that:

var url = 'http://graph.facebook.com/myname/feed'; $.getJSON(url+'&callback=?',function(json){...});

Since June 4th. I go开发者_StackOverflow社区t the Facebook message that I need an user access_token. BUT where/how can i get this token? And what do i have to do if i want to use this token all my lofe long?


I had the same issue and made a walkaround using a "gate" php like this:

// 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;

Having this script, all you have to do is change the call to this instead of https://graph.facebook.com/......

I hope this helps you, It worked for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜