Reputation: 105
I have to get value of access_token
from a URL, like:
localhost/facebook/#access_token=xyz
$_GET['access_token']
doesn't work. How can I get the value of access_token
?
Upvotes: 0
Views: 113
Reputation: 3814
Use getAccessToken
$facebook->getAccessToken();
https://developers.facebook.com/docs/reference/php/facebook-getAccessToken/
$user = $facebook->getUser();
echo $facebook->getAccessToken();
if(!$user){
$loginUrl = $facebook->getLoginUrl();
echo '<a href="$loginUrl">Login with Facebook</a>';
}
Clicking login with take you to fb, you login/accept whatever, then it redirects you back to your page and you get your access token.
Upvotes: 1
Reputation: 2016
I believe the hash part of the URL isn't sent to PHP, so can't be accessed via PHP. Javascript can access it, and can then pass it onto PHP.
There is a guide here showing how.
Upvotes: 0