joetannenbaum / phpushbullet
Pushbullet 的 PHP API 封装。
1.2.2
2016-06-15 18:18 UTC
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ~5.3|~6.0
Requires (Dev)
- phpunit/phpunit: 4.1.*
README
PHP 推送弹球 API 的库。
目录
安装
使用 composer
{
"require": {
"joetannenbaum/phpushbullet": "~1.0"
}
}
PHPushbullet 接受一个可选参数,你的 Pushbullet 访问令牌
require_once('vendor/autoload.php'); $pushbullet = new PHPushbullet\PHPushbullet('YOUR_ACCESS_TOKEN_HERE');
如果你不想在你的代码中放置访问令牌(可以理解),只需将其设置为环境变量 pushbullet.access_token
,PHPushbullet 将自动获取它。
列出设备
要列出你账号上的可用设备
$pushbullet->devices();
这将返回一个包含所有设备信息的对象数组。
推送
到设备
推送到一个设备时,只需使用列表上设备的 nickname
或他们的 iden
。
推送到一个单独的设备
$pushbullet->device('Chrome')->note('Remember', 'Buy some eggs.');
推送到多个设备
$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.');
到用户
推送到一个用户时,只需使用用户的电子邮件地址
推送到一个单独的用户
$pushbullet->user('joe@example.com')->note('Remember', 'Buy some eggs.');
推送到多个用户
$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.');
类型
笔记
参数
- 标题
- 正文
$pushbullet->device('Chrome')->note('Musings', 'Why are fudgy brownies better than cakey brownies?');
链接
参数
- 标题
- URL
- 正文(可选)
$pushbullet->device('Chrome')->link('Look It Up', 'http://google.com', 'I hear this is a good site for finding things.');
地址
参数
- 名称
- 地址
$pushbullet->device('Chrome')->address('The Hollywood Sign', '4059 Mt Lee Drive Hollywood, CA 90068');
或者,你可以传递一个关联数组
$address = [ 'address' => '4059 Mt Lee Drive', 'city' => 'Hollywood', 'state' => 'CA', 'zip' => '90068', ]; $pushbullet->device('Chrome')->address('The Hollywood Sign', $address);
列表
参数
- 标题
- 项目(数组)
$items = [ 'Socks', 'Pants', 'Keys', 'Wallet', ]; $pushbullet->device('Chrome')->list('Do Not Forget', $items);
文件
参数
- 文件名
- 文件 URL(必须是公开可用的)
- 正文(可选)
$pushbullet->device('Chrome')->file('The Big Presentation', 'http://example.com/do-not-lose-this.pptx', 'Final version of slides.');