您好,
if (isset($_GET['code'])) {
// try to get an access token
$code = $_GET['code'];
$url = '<token endpoint here>'; // Token endpoint
$params = array(
"grant_type" => "authorization_code",
"code" => $code,
"redirect_uri" => '<redirect uri here>',
"scope" => "openid",
);
$client_id = '<client id here>';
$client_secret = '<client secret here>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, array("Authorization: Basic".$client_id.":".$client_secret, 'Accept:application/json'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$output = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($output, 0, $header_size);
$body = substr($output, $header_size);
curl_close($ch);
print_r($header);print_r('this is'. $body);
die;
}
我正在获取带有某些状态HTTP/1.1 200 OK
的标头响应以及其他一些参数,例如内容类型等。但是我没有从这一端获得访问令牌。任何人都可以帮我解决问题。