Skip to content

Instantly share code, notes, and snippets.

@KiriKiri
Created May 20, 2015 12:12
Show Gist options
  • Save KiriKiri/473107d52f76893c9c52 to your computer and use it in GitHub Desktop.
Save KiriKiri/473107d52f76893c9c52 to your computer and use it in GitHub Desktop.
function send_push_notification ($platform, $token, $msg) {
$data = array (
'platform' => $platform,
'token' => $token,
'msg' => $msg,
'sound' => '',
'badge' => '1',
'payload' => array(),
);
$log = 'Sending push: '.json_encode($data)."\r\n";
file_put_contents ($_SERVER['DOCUMENT_ROOT']."/log/pushbots_requests.txt" , $log."\r\n", FILE_APPEND );
echo $log;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.pushbots.com/push/one');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'x-pushbots-appid: PUSHBOTS_APP_ID',
'x-pushbots-secret: PUSHBOTS_APP_SECRET',
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST, true);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
var_dump($response);
var_dump($error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment