예제 #1
0
*/
// Show all errors/warnings
error_reporting(E_ALL);
ini_set('display_errors', '1');
const NEWLINE = '<br /><br />';
require 'Pocket.php';
$params = array('consumerKey' => '');
if (empty($params['consumerKey'])) {
    die('Please fill in your Pocket App Consumer Key');
}
$pocket = new Pocket($params);
if (isset($_GET['authorized'])) {
    // Convert the requestToken into an accessToken
    // Note that a requestToken can only be covnerted once
    // Thus refreshing this page will generate an auth error
    $user = $pocket->convertToken($_GET['authorized']);
    /*
    	$user['access_token']	the user's access token for calls to Pocket
    	$user['username']	the user's pocket username
    */
    print_r($user);
    // Set the user's access token to be used for all subsequent calls to the Pocket API
    $pocket->setAccessToken($user['access_token']);
    echo NEWLINE;
    // Add a url to the user's pocket
    // http://getpocket.com/developer/docs/v3/add for a list of params
    $params = array('url' => 'https://github.com/djchen/', 'tags' => 'github');
    print_r($pocket->add($params, $user['access_token']));
    echo NEWLINE;
    // Retrieve the user's list of unread items (limit 5)
    // http://getpocket.com/developer/docs/v3/retrieve for a list of params