2017 © Pedro PelĆ”ez
 

library pokket-php

PHP SDK to access the Pocket API

image

bouiboui/pokket-php

PHP SDK to access the Pocket API

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

pokket-php

Latest Version on Packagist ![Software License][ico-license] SensioLabsInsight, (*1)

PHP SDK to access the Pocket API (v3, currently)., (*2)

Wait, why don't you call it Pocket API PHP SDK or something similar then?, (*3)

It's actually forbidden because businessā„¢., (*4)

I'm a big fan of Pocket and I have some ideas I want to try out thanks to its API. The other librairies I found on Github were either too small, too big, or not documented enough for my needs. duellsy/pockpack seems very nicely done, it's a shame I found it too late., (*5)

Install

``` bash $ composer require bouiboui/pokket-php, (*6)


## Usage *Note: For a complete example: [example/index.php](https://github.com/bouiboui/pokket-php/blob/master/example/index.php)* Initialize Pokket with your [Consumer key](https://getpocket.com/developer/apps/new) and Redirect URI (classic OAuth) ``` php $pokket = new PokketAPI( '1234-abcd1234abcd1234abcd1234', // Consumer key 'https://yourdomain.tld/' // Redirect uri );

First we ask the user to login, (*7)

``` php if (!array_key_exists('pokket.token.request', $_SESSION)) { $pokket->requestUserAccess($_SESSION['pokket.token.request'] = $pokket->getRequestToken()); }, (*8)

Then we fetch an Access token

``` php
if (!array_key_exists('pokket.token.access', $_SESSION)) {
    $_SESSION['pokket.token.access'] = $pokket->getAccessToken($_SESSION['pokket.token.request']);
}
$pokket->setAccessToken($_SESSION['pokket.token.access']);

Now we can get down to businessā„¢, (*9)

``` php // Retrieve user posts $retrieveQuery = RetrieveQuery::build() ->withState(RetrieveQuery::STATE_UNREAD) ->withSort(RetrieveQuery::SORT_TITLE) ->withDetailType(RetrieveQuery::DETAIL_TYPE_SIMPLE) ->withCount(100);, (*10)

$posts = $pokket->retrieve($retrieveQuery);, (*11)

// Display results header('Content-type: application/json;Charset=utf8'); echo json_encode($posts);, (*12)


The code above returns (minus the *pretty format*): ```json { "status": 1, "complete": 1, "list": { "2093856": { "item_id": "2093856", "resolved_id": "2093856", "given_url": "http://www.csie.ntu.edu.tw/~cjlin/libsvm/", "given_title": "", "favorite": "0", "status": "0", "time_added": "1390842458", "time_updated": "1390927561", "time_read": "0", "time_favorited": "0", "sort_id": 74, "resolved_title": "LIBSVM -- A Library for Support Vector Machines", "resolved_url": "http://www.csie.ntu.edu.tw/~cjlin/libsvm/", "excerpt": "LIBSVM -- A Library for Support Vector Machines Chih-Chung Chang and Chih-Jen Lin Version 3.19 released on October 27, 2014. It conducts some minor fixes.LIBSVM tools provides many extensions of LIBSVM. Please check it if you need some functions not supported in LIBSVM.", "is_article": "0", "is_index": "1", "has_video": "0", "has_image": "1", "word_count": "961" }, " ... and 99 more elements ... " }, "error": null, "search_meta": { "search_type": "normal" }, "since": 1460836019 }

Credits

License

Unlicense. Public domain, basically. Please treat it kindly. See License File for more information., (*13)

This project uses the following open source projects - guzzle/guzzle by Michael Dowling — License., (*14)

The Versions

13/09 2016

dev-master

9999999-dev

PHP SDK to access the Pocket API

  Sources   Download

Unlicense

The Requires

 

api sdk pocket

13/09 2016

0.2

0.2.0.0

PHP SDK to access the Pocket API

  Sources   Download

Unlicense

The Requires

 

api sdk pocket

16/04 2016

v0.1

0.1.0.0

PHP SDK to access the Pocket API

  Sources   Download

Unlicense

The Requires

 

api sdk pocket