/**
  * Connect to Pocket grab data
  *
  * @param $post_settings_array
  *
  * @return $saves
  */
 public function connect_to_pocket($post_settings_array)
 {
     $args = array('consumerKey' => $post_settings_array['consumer_key']);
     $pocket = new Pocket($args);
     // Retrieve the user's list of both unread and archived items (min. limit 5)
     // http://getpocket.com/developer/docs/v3/retrieve for a list of parameters
     $params = array('state' => 'all', 'sort' => 'newest', 'detailType' => 'complete', 'count' => 10);
     $saves = $pocket->retrieve($params, $post_settings_array['access_token']);
     return $saves;
 }
示例#2
0
    	$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
    $params = array('state' => 'unread', 'sort' => 'newest', 'detailType' => 'simple', 'count' => 5);
    $items = $pocket->retrieve($params, $user['access_token']);
    print_r($items);
} else {
    // Attempt to detect the url of the current page to redirect back to
    // Normally you wouldn't do this
    $redirect = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?authorized=';
    // Request a token from Pocket
    $result = $pocket->requestToken($redirect);
    /*
    	$result['redirect_uri']		this is the URL to send the user to getpocket.com to authorize your app
    	$result['request_token']	this is the request_token which you will need to use to
    					obtain the user's access token after they have authorized your app
    */
    /*
    This is a hack to redirect back to us with the requestToken
    Normally you should save the 'request_token' in a session so it can be