【问题标题】:How do I get the facebook user access_token for my feed如何为我的提要获取 facebook 用户 access_token
【发布时间】:2011-09-09 22:50:51
【问题描述】:

我正在使用 jQuery 处理我 Facebook 墙上的 json 数据。对我的 json 文件的调用是这样的:

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

自 6 月 4 日起。我收到了我需要用户 access_token 的 Facebook 消息。但是我在哪里/如何获得这个令牌?如果我想在我的一生中使用这个令牌,我该怎么办?

【问题讨论】:

    标签: facebook access-token


    【解决方案1】:

    我遇到了同样的问题,并使用这样的“门”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/......

    我希望这对你有帮助,它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多