我正在尝试获取 Access_token,我需要在 adsense 主机 api 中使用它来授权我的请求,并且我有这样的代码
$curlHandle = curl_init();
$data = array(
'code' => 'AFC',
'client_id' => 'myClientId',
'client_secret'=> 'myClientSecret',
'redirect_uri' => 'http://smk.dev',
'grant_type'=>'authorization_code'
);
$url = 'https://accounts.google.com/o/oauth2/token';
curl_setopt($curlHandle,CURLOPT_URL,$url);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curlHandle, CURLOPT_POST, 1);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curlHandle);
$data = json_decode($result);
但是我收到错误“invalid_grant”的响应,所以我错在哪里?什么是代码参数?我使用来自 google adsense host api 的参数