3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
Output for 7.0.0 - 7.2.0
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 hhvm-3.10.1 - 3.11.1, hhvm-3.13.2, hhvm-3.17.3
Array ( [code] => 0 [result] => )
Output for hhvm-3.12.14, hhvm-3.15.4

Process exited with code 137.
Output for 5.0.0 - 5.6.30
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.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.