@ 2015-11-19T10:58:55Z <?php
//Initialisation des variables
$clientId = "14254";
$consumerKey = "MTQyNTQ6";
$consumerSecret = "69e94237bdb84f55ba692ef88a925e21";
// Header de la requête
$headers = array(
"grant_type" => "password",
"client_id" => $clientId,
"username" => $consumerKey,
"password" => $consumerSecret,
"content_type" => "application/x-www-form-urlencoded"
);
$postText = http_build_query($headers);
// URL d'appel
$url = "https://api.ccmp.eu/services/authorization/oauth2/token";
try {
// Initialisation de la session CURL
$curl = curl_init();
// Appel de l'URL en paramètre
curl_setopt($curl, CURLOPT_URL, $url);
//HTTP POST request
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postText);
// Demande le résultat en chaîne de caractères
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Execution de la session CURL
$result = curl_exec($curl);
// Récupère le code de la réponse retournée
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Fermeture de la session CURL
curl_close($curl);
// Création d'un tableau contenant le code de retour et le résultat de la requête
$res = array_merge(array('code' => $code), array('result' => json_decode($result, true)));
} catch ( Exception $e ) {
throw new Exception("Error during the call. Here the message: " . $e -> Message);
}
print_r($res);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.19 , 8.3.0 - 8.3.7 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/9uIjS:22
Stack trace:
#0 {main}
thrown in /in/9uIjS on line 22
Process exited with code 255 . Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 Fatal error: Call to undefined function curl_init() in /in/9uIjS on line 22
Process exited with code 255 . Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected '{' in /in/9uIjS on line 20
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected '{' in /in/9uIjS on line 20
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error in /in/9uIjS on line 20
Process exited with code 255 . preferences:dark mode live preview
282.63 ms | 401 KiB | 459 Q