Question

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?

Was it helpful?

Solution

$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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top