Skip to content

Instantly share code, notes, and snippets.

@zincplusplus
Last active January 21, 2016 13:18
Show Gist options
  • Save zincplusplus/909576924d7d5af87673 to your computer and use it in GitHub Desktop.
Save zincplusplus/909576924d7d5af87673 to your computer and use it in GitHub Desktop.
Pushover + PHP API Implementation
<?php
function pushNotification($message) {
// create curl resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.pushover.net/1/messages.json");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
// (required) - your application's API token
"token" => "$$$$$$$$$$"
// (required) - the user/group key (not e-mail address) of your user (or you), viewable when logged into our dashboard (often referred to as USER_KEY in our documentation and code examples)
, "user" => "$$$$$$$$$$"
// (required) - your message
, "message" => $message
// Some optional parameters may be included:
// your user's device name to send the message directly to that device, rather than all of the user's devices (multiple devices may be separated by a comma)
, "device" => "$$$$$$$$$$"
// your message's title, otherwise your app's name is used
, "title" => "$$$$$$$$$$"
// a supplementary URL to show with your message
// , "url" => ""
// does the text contain HTML?
// , "html" => "1"
// a title for your supplementary URL, otherwise just the URL is shown
// , "url_title" => ""
// send as -2 to generate no notification/alert, -1 to always send as a quiet notification, 1 to display as high-priority and bypass the user's quiet hours, or 2 to also require confirmation from the user
// , "priority" => ""
// a Unix timestamp of your message's date and time to display to the user, rather than the time your message is received by our API
// , "timestamp" => ""
// - the name of one of the sounds supported by device clients to override the user's default sound choice
// "sound" => ""
));
$response = curl_exec($ch);
curl_close($ch);
echo "Push notification: " . $message;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment