A PHP client for Pushover.net

Installs: 539

Dependents: 0

Stars: 28

Watchers: 1

Forks: 1

Open Issues: 1

v1.4.2 2015-10-28 03:03 UTC


Latest Stable Version Build Status


Pushy is a PHP client that makes communicating with Pushover.net's API simple.

Pushy makes full use of Pushover's API. This includes sending messages, validating users, and retrieving message statuses.

Interested in sending real-time mobile notifications to your iOS or Android device(s) from your web app? Take a look at Pushover.net. API usage is free, and extremely easy to use with Pushy!


  • PHP 5.4+
  • cURL extension


You can install Pushy by using composer. Simply add the dependency to your composer.json configuration:

  "require": {
    "sqmk/pushy": "dev-master"

See composer and packagist for more information.


Assuming your composer generated or custom autoloader can load Pushy files properly, using it is simple!

For those interested in the complete API, you can check out the auto-generated documentation at GitApiDoc.

Initializing client

In order to send a message, verify a user, or get a message status, you'll first need an application API key. You can get an API key by registering a new application on Pushover.net.

Once you acquire your application key, you can now instantiate a Pushy Client object.

// Instantiate a client object with application key
$pushy = new Pushy\Client('KzGDORePK8gMaC0QOYAMyEEuzJnyUi');

Sending messages

You have a client instantiated, now you can send a message. But first, you want to build a user object for the receiving user.

You'll need to get your user identifier (or user key) at Pushover.net. You'll also want a registered device name if you want to send a message to a single device. You can now create a user object with these details.

// Instantiate a user object (targets all devices)
$user = new Pushy\User('pQiRzpo4DXghDmr9QzzfQu27cmVRsG');

// Alternatively, instantiate a user object with a targeted device
$user = new Pushy\User('pQiRzpo4DXghDmr9QzzfQu27cmVRsG', 'droid2');

// Setting properties by chaining is also possible
$user = (new Pushy\User('pQiRzpo4DXghDmr9QzzfQu27cmVRsG'))

After creating a user, you have enough to start creating a message.

// Instantiate a message object with a message body
$message = new Pushy\Message('Your message body');

// Set the recipient of the message

// Set the title
$message->setTitle('You message title');

// Set a priority (defaults to NormalPriority)
  new Pushy\Priority\LowPriority

// Set a sound (defaults to PushoverSound)
  new Pushy\Sound\AlienSound

// Set a supplementary URL and title


// Set a custom sent timestamp

// All methods above are chainable
$message = (new Pushy\Message)
  ->setMessage('Your message body')
  ->setTitle('Your message title')

To send the message, pass the message object to the client.

// Send the previous created message

If no exceptions are thrown, the message was sent successfully. No data is returned by the sendMessage method unless the message has an emergency priority.

Emergency priority messages

You can send a message with an emergency priority and get a receipt id. Emergency priorities also have additional options.

// Create a message with emergency priority
$message = (new Pushy\Message)
  ->setMessage('Important message')
  ->setTitle('Important subject')
    (new Pushy\Priority\EmergencyPriority)
      // Resend message to user every X seconds
      // Expire message after X seconds
      // Set callback URL to hit when user acknowledges message

// Send message and get receipt id
$receiptId = $pushy->sendMessage($message);

With a receipt Id, you can cancel messages with an emergency priority:


The list of available priorities in Pushy\Priority:

  • LowestPriority
  • LowPriority
  • NormalPriority (default)
  • HighPriority
  • EmergencyPriority

The list of available sounds in Pushy\Sound:

  • AlienSound
  • BikeSound
  • BugleSound
  • CashregisterSound
  • ClassicalSound
  • ClimbSound
  • CosmicSound
  • EchoSound
  • FallingSound
  • GamelanSound
  • IncomingSound
  • IntermissionSound
  • MagicSound
  • MechanicalSound
  • NoSound
  • PersistentSound
  • PianobarSound
  • PushoverSound (default)
  • SirenSound
  • TugboatSound
  • UpdownSound

Verifying a user

A user object can be verified with Pushover prior to sending out messages.

// Pass previous instantiated user object to the client
try {

  echo 'User is valid';
} catch (Pushy\Transport\Exception\ApiException $e) {
  echo 'User is not valid';

Getting message status

When using an emergency priority with a message, you get a receipt code after sending the message successfully. You can get the status of the message by sending the receipt code by way of getMessageStatus.

// Get message with the receipt code
$messageStatus = $pushy->getMessageStatus($receiptCode);

// Was the message acknowledged? (true or false)

// When the message was acknowledged (DateTime or null)

// When the message was last delivered (DateTime or null)

// Is the message expired? (true or false)

// When the message expired (DateTime or null)

// Has Pushover contacted the callback URL? (true or false)

// When Pushover contacted the callback URL (DateTime or null)

Getting application limitations

Pushover.net allows you to send 7,500 messages per month for each application you own. Sending more than that limit will result in rejected requests from the service.

Pushy provides 3 convenience methods on the client to retrieve your app's message limit, remaining messages, and timestamp for when the limit is reset. These values are available after making any other request to Pushover.

// Call limit for the application per month.

// Calls remaining for the month.

// Timestamp for when calls remaining is reset to limit.

Command-line Interface

Included in Pushy is a convenient script to send messages from the command line.

You can call it like so:

$ bin/pushy --token=yourtokenhere --user-id=useridhere --message="Message here" --title="Title here" --url="http://example.org" --url-title="Example.org" --timestamp=123456 --sound=echo --priority=high