1. Go to this page and download the library: Download sqmk/pushy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sqmk / pushy example snippets
// Instantiate a client object with application key
$pushy = new Pushy\Client('KzGDORePK8gMaC0QOYAMyEEuzJnyUi');
// 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'))
->setDeviceName('droid2');
// Instantiate a message object with a message body
$message = new Pushy\Message('Your message body');
// Set the recipient of the message
$message->setUser($user);
// Set the title
$message->setTitle('You message title');
// Set a priority (defaults to NormalPriority)
$message->setPriority(
new Pushy\Priority\LowPriority
);
// Set a sound (defaults to PushoverSound)
$message->setSound(
new Pushy\Sound\AlienSound
);
// Set a supplementary URL and title
$message->setUrl(
'http://example.org'
);
$message->setUrlTitle(
'Example.org'
);
// Set a custom sent timestamp
$message->setTimestamp(1369111110);
// All methods above are chainable
$message = (new Pushy\Message)
->setMessage('Your message body')
->setTitle('Your message title')
->setUser($user);
// Send the previous created message
$pushy->sendMessage($message);
// Create a message with emergency priority
$message = (new Pushy\Message)
->setMessage('Important message')
->setTitle('Important subject')
->setUser($user)
->setPriority(
(new Pushy\Priority\EmergencyPriority)
// Resend message to user every X seconds
->setRetry(30)
// Expire message after X seconds
->setExpire(3600)
// Set callback URL to hit when user acknowledges message
->setCallback('http://example.org/api')
);
// Send message and get receipt id
$receiptId = $pushy->sendMessage($message);
$pushy->cancelEmergency($receiptId);
// Pass previous instantiated user object to the client
try {
$pushy->verifyUser($user);
echo 'User is valid';
} catch (Pushy\Transport\Exception\ApiException $e) {
echo 'User is not valid';
}
// Get message with the receipt code
$messageStatus = $pushy->getMessageStatus($receiptCode);
// Was the message acknowledged? (true or false)
$messageStatus->isAcknowledged();
// When the message was acknowledged (DateTime or null)
$messageStatus->acknowledgedAt();
// When the message was last delivered (DateTime or null)
$messageStatus->lastDeliveredAt();
// Is the message expired? (true or false)
$messageStatus->isExpired();
// When the message expired (DateTime or null)
$messageStatus->expiresAt();
// Has Pushover contacted the callback URL? (true or false)
$messageStatus->hasCalledBack();
// When Pushover contacted the callback URL (DateTime or null)
$messageStatus->calledBackAt();
// Call limit for the application per month.
$pushy->getAppLimit();
// Calls remaining for the month.
$pushy->getAppRemaining();
// Timestamp for when calls remaining is reset to limit.
$pushy->getAppReset();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.