这让我疯了!
如果方法是POST,为什么Azure返回" AADSTS90056:此端点仅接受POST,OPTIONS请求。收到GET请求"错误?
代码:
$url='http://login.microsoftonline.com/common/oauth2/v2.0/token';
$data = array('code'=>$code,'resource'=>$resource,'redirect_uri' => $redirect_uri, 'client_id' => $client_ID, 'scope' => $scope, 'grant_type' => $grant_type, 'client_secret' => $client_secret);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);