dongquanyu5816 2014-12-15 18:03
浏览 109
已采纳

可以通过Facebook Graph API获取我当前的位置吗?

I am trying to build a portion into my personal website that shows the locations I have tagged in my posts on facebook. My understanding is that I need to do an oAuth Request on the server to get the AccessToken:

UPDATE

I built a php file that gets a file with the token in it and refreshes it. I can call this file with a cron job every hour and have an unlimited token. It looks like this:

    $appID = "APPID";
    $appSecret = "APPSECRET";
    $currentToken = file_get_contents(__DIR__."/token.txt");
    $url = "https://graph.facebook.com/oauth/access_token?client_id=".$appID."&client_secret=".$appSecret."&grant_type=fb_exchange_token&fb_exchange_token=".$currentToken;
    $ci = curl_init();
    curl_setopt($ci, CURLOPT_URL, $url);
    curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ci, CURLOPT_TIMEOUT, 10);
    curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ci, CURLOPT_FOLLOWLOCATION, TRUE);

    $newtoken = curl_exec($ci);
    curl_close ($ci);

    $newtoken = str_replace("access_token=","",$newtoken);
    $newtoken = substr($newtoken, 0,strpos($newtoken, "&expires=",0));

    if($newtoken == "")
    {
        echo "error";
    }
    else
    {
        $file = __DIR__."/token.txt";
        file_put_contents($file, $newtoken);
        echo $newtoken;
    }
  • 写回答

1条回答 默认 最新

  • dsfasdfsda234234 2014-12-16 08:13
    关注

    If the Access Token has the form {app_id}|{app_secret}, you're not using a User Access Token, but an App Access Token.

    Seems like you don't implement the proper Login process to gather the User Access Token. Stick to the provided sample code of the FB PHP SDK.

    See

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料