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

preferences:
37.38 ms | 402 KiB | 5 Q