There could be a few issues:
You could simplify a few things and use
http_build_query()
:$data = http_build_query(array( 'grant_type' => 'client_credentials', 'client_id' => CLIENT_ID, 'client_secret' => ACCESS_KEY, 'scope' => 'urn:WindowsAzureMediaServices', )); $ch = curl_init(TOKEN_URL); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if (($res = curl_exec($ch)) === false) { die(curl_error($ch)); } $arrToken = json_decode($res);
If there's an error, the first thing to make sure is whether you have an updated list of CA certificates.