我已经在Stackoverflow中挖掘了几个小时,但我仍然没有设法解决这个问题:(我想用Curl进行POST请求以获取Auth令牌,但是即使我:-确保未注释掉extension=php_curl.dll
-尝试了不同版本的PHP-下载了固定的curl扩展并替换了(https://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/)
我的代码:
function getToken() {
echo "start gettoken";
$jsonStr = http_build_query(Array(
"client_id" => "***",
"scope" => "https://graph.microsoft.com/.default",
"client_secret" => "***",
"grant_type" => "client_credentials"
));
$headers = Array("Content-Type: application/x-www-form-urlencoded");
$ch = curl_init("https://login.microsoftonline.com/***.onmicrosoft.com/oauth2/v2.0/token");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$token = curl_exec($ch);
echo "test after curl";
var_dump($token);
echo $token;
return $token;
curl_error($ch);
}
some1可以帮我一个忙吗?>
我已经在Stackoverflow中挖掘了几个小时,但我仍然没有设法解决这个问题:(我想用Curl进行POST请求以获取Auth令牌,但是即使我:-确保extension = ...
启用php_curl.dll
扩展名,似乎已被禁用。您可以使用