承接 pcs/pushbullet 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pcs/pushbullet

Composer 安装命令:

composer require pcs/pushbullet

包简介

Push notifications to devices and browsers via Pushbullet

README 文档

README

Description

A PHP library for the Pushbullet API allowing you to send all supported push notification types, manage contacts, send SMS messages, create/delete channels, and manage channel subscriptions.

For more information, you can refer to these links:

Requirements

Install

Create a composer.json file in your project root:

{
    "require": {
        "pcs/pushbullet": "4.*"
    }
}

Run php composer.phar install to download the library and its dependencies.

Quick Documentation

Add this line to include Composer packages:

<?php
require 'vendor/autoload.php';

Initialize Pushbullet with your API key:

// Get your access token here: https://www.pushbullet.com/account
$pb = new Pushbullet\Pushbullet('YOUR_ACCESS_TOKEN');

If you use PHP for Windows it may be necessary to point cURL to a CA certificate bundle, or disable SSL certificate verification altogether:

Pushbullet\Connection::setCurlCallback(function ($curl) {
	// Get a CA certificate bundle here:
    // https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt
    curl_setopt($curl, CURLOPT_CAINFO, 'C:/path/to/ca-bundle.crt');

	// Not recommended! Makes communication vulnerable to MITM attacks:
    // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
});

Devices

To list all active devices on your account:

$pb->getDevices();

Returns an array of Device objects.

You can target a particular device by using its iden or nickname:

$pb->device("Galaxy S4")->getPhonebook();

Returns an array of PhonebookEntry objects with names and phone numbers.

To target all available devices for pushing:

$pb->allDevices()->pushAddress("Google HQ", "1600 Amphitheatre Parkway");

This will send the address to all devices, and return a Push object.

Push Notifications

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.

Note

Arguments:

  • Title
  • Body
$pb->device("Galaxy S4")->pushNote("Hello world!", "Lorem ipsum...");

Link

Arguments:

  • Title
  • URL
  • Body
$pb->device("Galaxy S4")->pushLink("pcs on GitHub", "https://github.com/pcs", "Look at my page!");

Address

Arguments:

  • Name - the place's name.
  • Address - the place's address or a map search query.
$pb->device("Galaxy S4")->pushAddress("Google HQ", "1600 Amphitheatre Parkway");

List

Arguments:

  • Title
  • Array of items in the list
$pb->device("Galaxy S4")->pushList("Shopping List", [
	"Milk",
	"Butter",
	"Eggs"
]);

File

Arguments:

  • File path
  • MIME type (optional) - if null, MIME type will be magically guessed
  • Title (optional)
  • Body (optional)
  • Alternative file name (optional) - push the file as if it had this file name
$pb->device("Galaxy S4")->pushFile(
	"/home/pcs/photos/20150314_092653.jpg",
	"image/jpeg",
	"Look at this photo!",
	"I think it's pretty cool",
	"coolphoto.jpg"
);

SMS Messaging

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.

$pb->device("Galaxy S4")->sendSms("+359123", "Hello there!");

Send an SMS text to all people in a device's phonebook:

$people = $pb->device("Galaxy S4")->getPhonebook();

foreach ($people as $person) {
	$person->sendSms("Happy New Year!");
}

Channel Management

Get a list of channel subscriptions:

$pb->getChannelSubscriptions();

Returns an array of Channel objects with subscription information.

To subscribe or unsubscribe from channels:

$pb->channel("greatchannel")->subscribe();
$pb->channel("mehchannel")->unsubscribe();

Subscribing to a channel will return a Channel object with subscription information.

Get a list of channels created by the current user:

$pb->getMyChannels();

Returns an array of Channel objects.

Contact Management

Contacts are people you can send push notification to. They are not to be confused with entries in a device's phonebook.

To list contacts on your account:

$pb->getContacts();

Returns an array of Contact objects.

To create a contact:

$pb->createContact("John Doe", "johndoe@example.com");

Returns a Contact object for the newly created contact.

You can target a particular contact by its email or name:

$pb->contact("johndoe@example.com")->pushNote("Hey John!", "Where are you?");

To delete a contact:

$pb->contact("Caroline")->delete();

To change a contact's name:

$pb->contact("William")->changeName("Bill");

Returns a Contact object with an updated name.

For more detailed documentation, please refer to the PHPDoc in the source files.

pcs/pushbullet 适用场景与选型建议

pcs/pushbullet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「notifications」 「windows」 「push」 「iphone」 「android」 「chrome」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 pcs/pushbullet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pcs/pushbullet 我们能提供哪些服务?
定制开发 / 二次开发

基于 pcs/pushbullet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 22
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 54
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-23