I have been digging in StackOverflow for hours now but I still didn't manage to resolve this :(
I want to do a POST request with Curl to get an Auth token, but even though I:
extension=php_curl.dll is not commented out My code:
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);
}
Can someone please help me with this issue?
If you have installed a new Apache and a new version of PHP, you can migrate to the new Apache with the configurations of the old one via Apache→version.
For me CURL worked with PHP7.4 but not the other versions, then by migrating to the new Apache with the migration of data from the old Apache it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With