[英]It is possible to get my current location via the Facebook Graph API?
我正在尝试在我的个人网站中构建一部分,以显示我在facebook上的帖子中标记的位置。 我的理解是,我需要在服务器上执行oAuth请求以获取AccessToken:
我建立了一个php文件,该文件获取了带有令牌的文件并刷新了它。 我可以每小时执行一次cron作业来调用此文件,并且具有无限令牌。 看起来像这样:
$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;
}
如果访问令牌的格式为{app_id}|{app_secret}
,则说明您不是在使用用户访问令牌,而是在使用应用访问令牌。
似乎您没有实施正确的登录过程来收集用户访问令牌。 遵循提供的FB PHP SDK示例代码。
看到
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.