简体   繁体   English

如何从FB图API响应中获取access_token

[英]How to get access_token from FB graph API response

I am generating access_token from FB graph API. 我正在从FB图API生成access_token。

Every thing is working fine and its giving me access_token on call back url 一切正常,它在回调URL上为我提供了access_token

Can anyone tell me how should i get this token for url to use in my php script. 谁能告诉我我应该如何获取此令牌以在php脚本中使用url。

After response url is : 回复网址后:

http://www.mysite.com/company/index.php?mod=details#access_token=170791786296375|4c9eaa63ed2bad5ac51662d4-1394587960|4ndIjiCJaAnqLSe8wOo_HaxUC90&expires_in=0 http://www.mysite.com/company/index.php?mod=details#access_token=170791786296375|4c9eaa63ed2bad5ac51662d4-1394587960|4ndIjiCJaAnqLSe8wOo_HaxUC90&expires_in=0

I am trying to get by 我正在努力

$_REQUEST['access_token'] $ _REQUEST [ 'ACCESS_TOKEN']

Bu can't get like this way. 卜不能这样子。 Can any one help me in this matter? 任何人都可以帮我解决这个问题吗?

$access_token = "";
if(preg_match("/access_token=([^&]+)/", $_SERVER['QUERY_STRING'], $matches)) {
    $access_token = $matches[1];
}

or 要么

$access_token = $_REQUEST['mod'];
$access_token = explode("#", $access_token);
$access_token = str_replace("access_token=", "", $access_token[1]);

or something like that 或类似的东西

if your doing it this way, you are doing it wrong. 如果您以这种方式这样做,则说明您做错了。 You are using the client side methods to send data to the server. 您正在使用客户端方法将数据发送到服务器。 You should be using the server side methods. 您应该使用服务器端方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM