link0/phpebble

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Package to interact with Pebble APIs

v0.1.1 2015-09-12 13:45 UTC

This package is not auto-updated.

Last update: 2021-09-18 01:26:47 UTC


README

Latest Stable Version Total Downloads License Scrutinizer Code Quality Code Coverage Build Status

This package encapsulates external services provided by Pebble to interact with the Pebble Smartwatch

License: MIT

Usage

You can install using composer

composer require link0/phpebble

Quickstart

<?php

use GuzzleHttp\Client;
use Link0\Phpebble\Api\GuzzleTimeline;
use Link0\Phpebble\Api\InvalidPinObject;
use Link0\Phpebble\Api\InvalidTimelineToken;
use Link0\Phpebble\Api\RateLimitExceeded;
use Link0\Phpebble\Api\ServiceUnavailable;
use Link0\Phpebble\Api\TimelineToken;
use Link0\Phpebble\Pin;

require_once('vendor/autoload.php');

$token = TimelineToken::fromString('0123456789abcdef0123456789abcdef');
$pin = Pin::create('foo-31337', new \DateTimeImmutable(), 'Some title');

$api = new GuzzleTimeline(new Client(), $token);

try {
    $api->push($pin);
    printf("%s\n", "Succesfully processed Pin " . $pin->id());
}
catch(InvalidPinObject $ipo) {
    printf("%s\n", $ipo->getMessage());
    print_r($ipo->pin());
}
catch(InvalidTimelineToken $itt) {
    printf("%s\n", $itt->getMessage());
    print_r($itt->timelineToken());
}
catch(RateLimitExceeded $rle) {
    printf("%s\n", $rle->getMessage());
}
catch(ServiceUnavailable $su) {
    printf("%s\n", $su->getMessage());
}