PHP code example of pcs / pushbullet

1. Go to this page and download the library: Download pcs/pushbullet library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pcs / pushbullet example snippets




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

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);
});

$pb->getDevices();

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

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

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

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

$pb->device("Galaxy S4")->pushAddress("Google HQ", "1600 Amphitheatre Parkway");

$pb->device("Galaxy S4")->pushList("Shopping List", [
	"Milk",
	"Butter",
	"Eggs"
]);

$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"
);

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

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

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

$pb->getChannelSubscriptions();

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

$pb->getMyChannels();

$pb->getContacts();

$pb->createContact("John Doe", "[email protected]");

$pb->contact("[email protected]")->pushNote("Hey John!", "Where are you?");

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

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