A PHP library for the Pushbullet API.
Using composer:
{
"require": {
"joetannenbaum/phpushbullet": "~1.0"
}
}
PHPushbullet takes one optional parameter, your Pushbullet access token:
require_once('vendor/autoload.php');
$pushbullet = new PHPushbullet\PHPushbullet('YOUR_ACCESS_TOKEN_HERE');
If you do not wish to put your access token in your code (understandable), simply set it to the environment variable pushbullet.access_token
and PHPushbullet will automatically pick it up.
To list the available devices on your account:
$pushbullet->devices();
This will return an array of objects with all of the device information.
When pushing a to a device, simply use the device's nickname
or their iden
from the list above.
To push to a single device:
$pushbullet->device('Chrome')->note('Remember', 'Buy some eggs.');
To push to multiple devices:
$pushbullet->device('Chrome')->device('Galaxy S4')->note('Remember', 'Buy some eggs.');
// or
$pushbullet->device('Chrome', 'Galaxy S4')->note('Remember', 'Buy some eggs.');
// or
$pushbullet->device(['Chrome', 'Galaxy S4'])->note('Remember', 'Buy some eggs.');
When pushing a to a user, simply use the user's email address:
To push to a single user:
$pushbullet->user('joe@example.com')->note('Remember', 'Buy some eggs.');
To push to multiple users:
$pushbullet->user('joe@example.com')->user('anne@example.com')->note('Remember', 'Buy some eggs.');
// or
$pushbullet->user('joe@example.com', 'anne@example.com')->note('Remember', 'Buy some eggs.');
// or
$pushbullet->user(['joe@example.com', 'anne@example.com'])->note('Remember', 'Buy some eggs.');
Arguments:
- Title
- Body
$pushbullet->device('Chrome')->note('Musings', 'Why are fudgy brownies better than cakey brownies?');
Arguments:
- Title
- URL
- Body (optional)
$pushbullet->device('Chrome')->link('Look It Up', 'http://google.com', 'I hear this is a good site for finding things.');
Arguments:
- Name
- Address
$pushbullet->device('Chrome')->address('The Hollywood Sign', '4059 Mt Lee Drive Hollywood, CA 90068');
Alternatively, you can pass in an associative array:
$address = [
'address' => '4059 Mt Lee Drive',
'city' => 'Hollywood',
'state' => 'CA',
'zip' => '90068',
];
$pushbullet->device('Chrome')->address('The Hollywood Sign', $address);
Arguments:
- Title
- Items (array)
$items = [
'Socks',
'Pants',
'Keys',
'Wallet',
];
$pushbullet->device('Chrome')->list('Do Not Forget', $items);
Arguments:
- File Name
- File URL (must be publicly available)
- Body (optional)
$pushbullet->device('Chrome')->file('The Big Presentation', 'http://example.com/do-not-lose-this.pptx', 'Final version of slides.');