PHP code example of bouiboui / pokket-php

1. Go to this page and download the library: Download bouiboui/pokket-php 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/ */

    

bouiboui / pokket-php example snippets

 bash
$ composer 
 php
$pokket = new PokketAPI(
    '1234-abcd1234abcd1234abcd1234', // Consumer key
    'https://yourdomain.tld/' // Redirect uri
);
 php
if (!array_key_exists('pokket.token.request', $_SESSION)) {
    $pokket->requestUserAccess($_SESSION['pokket.token.request'] = $pokket->getRequestToken());
} 
 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']);
 php
// Retrieve user posts
$retrieveQuery = RetrieveQuery::build()
    ->withState(RetrieveQuery::STATE_UNREAD)
    ->withSort(RetrieveQuery::SORT_TITLE)
    ->withDetailType(RetrieveQuery::DETAIL_TYPE_SIMPLE)
    ->withCount(100);

$posts = $pokket->retrieve($retrieveQuery);

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