如何从FB图API响应中获取访问令牌

如何从FB图API响应中获取访问令牌

问题描述:

I am generating access_token from FB graph API.

Every thing is working fine and its giving me access_token on call back url

Can anyone tell me how should i get this token for url to use in my php script.

After response url is :

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']

Bu can't get like this way. Can any one help me in this matter?

我正在从FB图形API生成access_token。 p>

每件事都在工作 很好,它在回调url时给我access_token p>

任何人都可以告诉我如何在我的php脚本中使用此令牌以便使用url。 p>

响应网址后: p>

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

我想通过 p>

$ _ REQUEST ['access_token'] p> blockquote>

Bu不能这样。 任何人都可以帮我解决这个问题吗? p> div>

$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.