run code in 200+ php & hhvm versions
Bugs & Features
<?php // Replace with the real server API key from Google APIs $apiKey = "AIzaSyBFtNb7a_TCtxSqkiWUc5qGKVJ1KJtIa0s"; // Replace with the real client registration IDs $registrationIDs = array("APA91bHxXsOqvgC9uGcdZ7rV0EukYbS7pQY4Y4wqMfeh4xtJ0F_vXzvN1Uk6g0mWz2opmcfUYM9VrlfFpPBj0ND4lHVOqbVAPU5FiJ03Q8AwrCb7UIuK67Sveh5yGCPsi_rPcTIbMjAk"); // Message to be sent $message = "hi Shailesh"; // Set POST variables $url = 'https://android.googleapis.com/gcm/send'; $fields = array( 'registration_ids' => $registrationIDs, 'data' => array( "message" => $message ), ); $headers = array( 'Authorization: key=' . $apiKey, 'Content-Type: application/json' ); // Open connection $ch = curl_init(); // Set the URL, number of POST vars, POST data curl_setopt( $ch, CURLOPT_URL, $url); curl_setopt( $ch, CURLOPT_POST, true); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true); //curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // curl_setopt($ch, CURLOPT_POST, true); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields)); // Execute post $result = curl_exec($ch); // Close connection curl_close($ch); echo $result; //print_r($result); //var_dump($result); ?>
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/vpIAA:24 Stack trace: #0 {main} thrown in /in/vpIAA on line 24
Process exited with code 255.
Output for hhvm-3.15.4
Output for 5.6.0 - 5.6.30
Fatal error: Call to undefined function curl_init() in /in/vpIAA on line 24
Process exited with code 255.