3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php //Initialisation des variables $clientId = "14254"; $consumerKey = "MTQyNTQ6NDQw"; $consumerSecret = "568a3e7ba52943b78587f2e86d9a57b8"; // 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); //set SSL curl_setopt($curl, CURLOPT_SSLVERSION, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 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);
based on QTjnj
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/RhXuB:22 Stack trace: #0 {main} thrown in /in/RhXuB on line 22
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Fatal error: Call to undefined function curl_init() in /in/RhXuB on line 22
Process exited with code 255.