here, copy the code, and paste it into the box below.
";
}
// step I, J - turn the authorization code into an access token, etc.
function getAccessToken($authorization_code)
{
global $token_url, $client_id, $client_secret, $callback_uri;
$authorization = base64_encode("$client_id:$client_secret");
$header = ["Authorization: Basic {$authorization}", 'Content-Type: application/x-www-form-urlencoded'];
$content = "grant_type=authorization_code&code=$authorization_code&redirect_uri=$callback_uri";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $token_url,
CURLOPT_HTTPHEADER => $header,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $content
]);
$response = curl_exec($curl);
$objectResponse = json_decode($response);
curl_close($curl);
if ($response === false) {
echo 'Failed', curl_error($curl);
} elseif (isset($objectResponse->error)) {
echo "Error:
$authorization_code $response";
}
return $objectResponse->access_token;
}