Answer the question
In order to leave comments, you need to log in
How to properly work with OAuth Facebook?
Trying to get basic Facebook user details using OAuth.
The code for getting the token is obtained.
To get the token I use file_get_contents
$params = array(
"client_id" => $app_id,
"redirect_uri" => $redirect_uri,
"client_secret" => $app_secret,
"code" => $_GET["code"]
);
$query = http_build_query($params);
$url = "https://graph.facebook.com/oauth/access_token?{$query}"
$url = "https://graph.facebook.com/oauth/access_token";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, urldecode(http_build_query($params)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
curl_close($curl);
$tokenInfo = json_decode($result);
echo $tokenInfo;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question