You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using this class, you can send push notifications to mobile and desktop devices running **Pushbullet**. The following types of push notifications can be sent:
6
-
* notes
7
-
* links
8
-
* addresses
9
-
* checklists
10
-
* files (smaller than 25 MB)
5
+
A PHP library for the **[Pushbullet](https://www.pushbullet.com)** API allowing you to send all supported push notification types, manage contacts, send SMS messages, create/delete channels, and manage channel subscriptions.
11
6
12
7
For more information, you can refer to these links:
13
8
***Official website**: https://www.pushbullet.com
@@ -17,113 +12,222 @@ For more information, you can refer to these links:
17
12
18
13
## Requirements
19
14
* PHP 5.4.0 or newer
15
+
* Composer
20
16
* cURL library for PHP
21
-
* Your Pushbullet API key (get it here: https://www.pushbullet.com/account)
17
+
* Your Pushbullet access token: https://www.pushbullet.com/account
22
18
23
19
## Install
24
-
25
-
Via Composer:
20
+
Create a `composer.json` file in your project root:
26
21
27
22
```json
28
23
{
29
24
"require": {
30
-
"ivkos/pushbullet": "2.*"
25
+
"ivkos/pushbullet": "3.*"
31
26
}
32
27
}
33
28
```
34
29
35
-
## Examples
30
+
## Quick Documentation
36
31
37
-
For more detailed usage information, consult the PHPDoc of the methods.
32
+
Add this line to include Composer packages:
38
33
39
34
```php
40
35
<?php
36
+
require 'vendor/autoload.php';
37
+
```
41
38
42
-
require __DIR__ . '/vendor/autoload.php';
43
-
44
-
// If you don't use Composer, include the class like so:
45
-
// require 'src/Pushbullet.php';
46
-
47
-
try {
48
-
#### AUTHENTICATION ####
49
-
// Get your API key here: https://www.pushbullet.com/account
50
-
$p = new Pushbullet('YOUR_API_KEY');
39
+
Initialize Pushbullet with your API key:
40
+
```php
41
+
// Get your access token here: https://www.pushbullet.com/account
42
+
$pb = new Pushbullet\Pushbullet('YOUR_ACCESS_TOKEN');
43
+
```
51
44
52
-
// If you get SSL errors while using the library, you may need to point cURL to a CA certificate bundle
53
-
$p->addCurlCallback(function ($curl) {
54
-
// Get a CA certificate bundle here:
45
+
If you use PHP for Windows it *may* be necessary to point cURL to a CA certificate bundle, or disable SSL certificate verification altogether:
// If the MIME type argument is omitted, an attempt to guess it will be made.
102
-
$p->pushFile('0PpyWzARDK0w6et', '../pic.jpg');
103
-
104
-
105
-
#### Pushing to multiple devices
106
-
107
-
// Push to all of your own devices, if you set the first argument to NULL or an empty string
108
-
$p->pushNote(NULL, 'Some title', 'Some text');
109
-
$p->pushNote('', 'Some title', 'Some text');
110
-
111
-
112
-
113
-
#### Delete methods
114
-
115
-
// Delete the push notification with the 'iden' specified
116
-
$p->deletePush('a91kkT2jIICD4JH');
117
-
118
-
// Delete the device with the 'iden' specified
119
-
$p->deleteDevice('s2GBpJqaq9IY5nx');
120
-
121
-
// Delete the contact with the 'iden' specified
122
-
$p->deleteContact('0PpyWzARDK0w6et');
123
-
} catch (PushbulletException $e) {
124
-
// Exception handling
125
-
die($e->getMessage());
54
+
});
55
+
```
56
+
57
+
### Devices
58
+
To list all active devices on your account:
59
+
```php
60
+
$pb->getDevices();
61
+
```
62
+
Returns an array of `Device` objects.
63
+
64
+
----------
65
+
66
+
You can target a particular device by using its `iden` or `nickname`:
67
+
```php
68
+
$pb->device("Galaxy S4")->getPhonebook();
69
+
```
70
+
Returns an array of `PhonebookEntry` objects with names and phone numbers.
71
+
72
+
### Push Notifications
73
+
You can use `push*` methods for `Contact`, `Channel` and `Device` objects. Every `push*` method returns a `Push` object. If an object cannot be pushed to, a `NotPushableException` will be thrown.
- MIME type (optional) - if `null`, MIME type will be magically guessed
125
+
- Title (optional)
126
+
- Body (optional)
127
+
- Alternative file name (optional) - push the file as if it had this file name
128
+
129
+
```php
130
+
$pb->device("Galaxy S4")->pushFile(
131
+
"/home/ivkos/photos/20150314_092653.jpg",
132
+
"image/jpeg",
133
+
"Look at this photo!",
134
+
"I think it's pretty cool",
135
+
"coolphoto.jpg"
136
+
);
137
+
```
138
+
139
+
### SMS Messaging
140
+
You can send SMS messages only from supported devices. If an attempt is made to send an SMS message from a device doesn't support it, a `NoSmsException` will be thrown.
0 commit comments