3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('APPKEY','XXXXXXXXXXXXXXX'); // Your app key define('PUSHSECRET', 'XXXXXXXXXXXXXXX'); // Your master Secret define('PUSHURL', 'https://go.urbanairship.com/api/push/'); $iosspecific = array(); $iosspecific['badge'] = "+1"; $iosspecific['sound'] = "cat.caf"; $notification = array(); $notification['alert'] = "PHP script test with rich push"; $notification['ios'] = $iosspecific; $platform = array(); array_push($platform, "ios"); array_push($platform, "android"); //comment out if you don't want Android $richpush = array(); $richpush['title'] = "Title of rich push"; $richpush['body'] = "Body of rich push"; $push = array("audience"=>"all", "notification"=>$notification, "device_types"=>$platform, "message"=>$richpush); $json = json_encode($push); echo $json; //show the payload $session = curl_init(PUSHURL); curl_setopt($session, CURLOPT_USERPWD, APPKEY . ':' . PUSHSECRET); curl_setopt($session, CURLOPT_POST, True); curl_setopt($session, CURLOPT_POSTFIELDS, $json); curl_setopt($session, CURLOPT_HEADER, False); curl_setopt($session, CURLOPT_RETURNTRANSFER, True); curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Accept: application/vnd.urbanairship+json; version=3;')); $content = curl_exec($session); echo $content; //show the response text // Check if any error occured $response = curl_getinfo($session); if($response['http_code'] != 202) { echo "Got negative response from server, http code: ". $response['http_code'] . "\n"; } else { echo "Wow, it worked!\n"; } curl_close($session); ?><?php
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
{"audience":"all","notification":{"alert":"PHP script test with rich push","ios":{"badge":"+1","sound":"cat.caf"}},"device_types":["ios","android"],"message":{"title":"Title of rich push","body":"Body of rich push"}} Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/DirYL:24 Stack trace: #0 {main} thrown in /in/DirYL on line 24
Process exited with code 255.
Output for 5.4.0 - 5.4.34, 5.5.0 - 5.5.18, 5.6.0 - 5.6.2, 7.3.32 - 7.3.33
Parse error: syntax error, unexpected end of file in /in/DirYL on line 45
Process exited with code 255.
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
{"audience":"all","notification":{"alert":"PHP script test with rich push","ios":{"badge":"+1","sound":"cat.caf"}},"device_types":["ios","android"],"message":{"title":"Title of rich push","body":"Body of rich push"}} Fatal error: Call to undefined function curl_init() in /in/DirYL on line 24
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/DirYL on line 21
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/DirYL on line 21
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/DirYL on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/DirYL on line 21

preferences:
198.14 ms | 401 KiB | 278 Q