forked from ivkos/Pushbullet-for-PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPushBullet.example.php
74 lines (47 loc) · 2.53 KB
/
PushBullet.example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
require 'PushBullet.class.php';
try {
#### AUTHENTICATION ####
// Get your API key here: https://www.pushbullet.com/account
$p = new PushBullet('YOUR_API_KEY');
#### Get methods
// Print the definitions for your own devices. Useful for getting the 'iden' for using with the push methods.
print_r($p->getDevices());
// Print the definitions for contacts/devices shared with you. Useful for getting 'iden', too.
print_r($p->getContacts());
// Print information about your Pushbullet account
print_r($p->getUserInformation());
// Print a list of sent push notifications, modified after 1400441645 unix time
print_r($p->getPushHistory(1400441645));
#### Push methods
// Push to email [email protected] a note with a title 'Hey!' and a body 'It works!'
$p->pushNote('[email protected]', 'Hey!', 'It works!');
// Push to device s2GBpJqaq9IY5nx a note with a title 'Hey!' and a body 'It works!'
$p->pushNote('s2GBpJqaq9IY5nx', 'Hey!', 'It works!');
// Push to device gXVZDd2hLY6TOB1 a link with a title 'ivkos at GitHub', a URL 'https://github.com/ivkos' and body 'Pretty useful.'
$p->pushLink('gXVZDd2hLY6TOB1', 'ivkos at GitHub', 'https://github.com/ivkos', 'Pretty useful.');
// Push to device a91kkT2jIICD4JH a Google Maps address with a name 'Google HQ' and an address '1600 Amphitheatre Parkway'
$p->pushAddress('a91kkT2jIICD4JH', 'Google HQ', '1600 Amphitheatre Parkway');
// Push to device qVNRhnXxZzJ95zz a to-do list with a title 'Shopping List' and items 'Milk' and 'Butter'
$p->pushList('qVNRhnXxZzJ95zz', 'Shopping List', array('Milk', 'Butter'));
// Push to device 0PpyWzARDK0w6et the file '../pic.jpg' of MIME type image/jpeg
// Method accepts absolute and relative paths.
$p->pushFile('0PpyWzARDK0w6et', '../pic.jpg', 'image/jpeg');
// If the MIME type argument is omitted, an attempt to guess it will be made.
$p->pushFile('0PpyWzARDK0w6et', '../pic.jpg');
#### Pushing to multiple devices
// Push to all of your own devices, if you set the first argument to NULL or an empty string
$p->pushNote(NULL, 'Some title', 'Some text');
$p->pushNote('', 'Some title', 'Some text');
#### Delete methods
// Delete the push notification with the 'iden' specified
$p->deletePush('a91kkT2jIICD4JH');
// Delete the device with the 'iden' specified
$p->deleteDevice('s2GBpJqaq9IY5nx');
// Delete the contact with the 'iden' specified
$p->deleteContact('0PpyWzARDK0w6et');
} catch (PushBulletException $e) {
// Exception handling
die($e->getMessage());
}
?>