joetannenbaum / phpushbullet
PHP API wrapper for Pushbullet.
Installs: 35 659
Dependents: 4
Suggesters: 0
Security: 0
Stars: 32
Watchers: 9
Forks: 14
Open Issues: 0
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ~5.3|~6.0
Requires (Dev)
- phpunit/phpunit: 4.1.*
README
A PHP library for the Pushbullet API.
Table of Contents
Installation
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.
Listing Devices
To list the available devices on your account:
$pushbullet->devices();
This will return an array of objects with all of the device information.
Pushing
To Devices
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.');
To Users
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.');
Types
Notes
Arguments:
- Title
- Body
$pushbullet->device('Chrome')->note('Musings', 'Why are fudgy brownies better than cakey brownies?');
Links
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.');
Addresses
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);
Lists
Arguments:
- Title
- Items (array)
$items = [ 'Socks', 'Pants', 'Keys', 'Wallet', ]; $pushbullet->device('Chrome')->list('Do Not Forget', $items);
Files
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.');