简体   繁体   中英

How to get access_token from FB graph API response

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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