• Stars
    star
    216
  • Rank 177,203 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 11 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP library for the Pushbullet API

Pushbullet for PHP

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": {
        "ivkos/pushbullet": "3.*"
    }
}

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("ivkos on GitHub", "https://github.com/ivkos", "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/ivkos/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", "[email protected]");

Returns a Contact object for the newly created contact.


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

$pb->contact("[email protected]")->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.

More Repositories

1

wallhaven4php

Wallhaven API for PHP - Search, filter and download wallpapers
PHP
36
star
2

Sofia-Public-Transport-API

Documentation for the Sofia Public Transport API
29
star
3

botyo

Modular chatbot framework designed for group chat rooms on Facebook
TypeScript
18
star
4

wallhaven4j

Wallhaven API for Java
Java
17
star
5

gpsd4j

gpsd client for Java
Java
11
star
6

sds011-client

JavaScript
7
star
7

tracker

GPS Vehicle Tracking System
Java
6
star
8

HexViewer

Console hex viewer written in C
C
3
star
9

split

Simple file splitter written in C
C
3
star
10

cloud-build-notifier

Sends email notifications for Google Cloud Build
TypeScript
2
star
11

CurrencyConverter

Simple currency converter written in C#
C#
2
star
12

luxaudio

Captures audio and creates spectrum visualizations on RGB LED strips
Go
2
star
13

linuxMemoryInfoPHP

Linux Memory Info Class for PHP
PHP
2
star
14

botyo-example

Botyo Example Project
TypeScript
1
star
15

iot-air-sensor

JavaScript
1
star
16

botyo-bundle-persistence

TypeScript
1
star
17

markovski

Markov chains for Node.js
JavaScript
1
star
18

uiss-client

node.js клиент за УИСС на Технически универститет - София
JavaScript
1
star
19

luxfx

Creates visual effects for WS2812B RGB LED strips. Remote control via REST
TypeScript
1
star
20

botyo-command-spotify

TypeScript
1
star
21

iot-weather-sensor

JavaScript
1
star
22

yuxel

Scrapes news sites, generates random headlines using Markov chains, and posts on Facebook. Designed for Google Cloud
TypeScript
1
star
23

botyo-command-youtube

TypeScript
1
star
24

nest-rest-template

Jump-start your Nest.js REST app with this opinionated template
TypeScript
1
star
25

botyo-api

Botyo API - The API for developing modules for Botyo
TypeScript
1
star