定制 duellsy/pockpack 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

duellsy/pockpack

Composer 安装命令:

composer require duellsy/pockpack

包简介

Package to handle communication with GetPocket.com API neatly.

README 文档

README

This package is for connecting to the Pocket API. check out their docs here

You'll need to register an app with pocket, and use the generated tokens provided in order for you to be able to connect to the API.

Build Status

Installation

Pockpack is installable via composer, the details are on packagist, here.

Add the following to the require section of your projects composer.json file:

"duellsy/pockpack": "2.*"

In files that you want to use the Pockpack classes, be sure to add the namespaces you're going to use to the top of the file similar to the following, so your code can reference the classes without issue

use Duellsy\Pockpack\Pockpack;
use Duellsy\Pockpack\PockpackAuth;
use Duellsy\Pockpack\PockpackQueue;

Authenticate

Get request token

$pockpath_auth = new PockpackAuth();
$request_token = $pockpath_auth->connect($consumer_key);

Redirect the user to pockets auth page

https://getpocket.com/auth/authorize?request_token=YOUR_REQUEST_TOKEN&redirect_uri=YOUR_REDIRECT_URI

Get users access token

$pockpack = new PockpackAuth();
$access_token = $pockpack->receiveToken($consumer_key, $request_token);

Get users access token and username

$pockpack = new PockpackAuth();
$data = $pockpack->receiveTokenAndUsername($consumer_key, $request_token);
$access_token = $data['access_token'];
$username = $data['username'];

Get reading list

Retreive reading list

This will return a full list of all active (unarchived) bookmarks, optionally you can have it also return extra information such as images. If you would prefer the result to be an array, you can send a second boolean value to the retrieve function set to true.

$pockpack = new Pockpack($consumer_key, $access_token);
$as_array = true; // false will return JSON, true will return an array
$list = $pockpack->retrieve($options[, $as_array]); // the second parameter is optional, defaults to false

The options array allows you to control exactly what is returned from the API. For the full list of options, please check 'Optional Parameters' section of the pocket retrieve API (you can also see an example JSON response on this page)

Example 1: show all favorited bookmarks, complete with images

$options = array(
    'state'         => 'all',
    'favorite'      => 1,
    'detailType'    => 'complete'
);

Example 2: show only unread bookmarks, complete with image

$options = array(
    'state'         => 'favorite',
    'detailType'    => 'complete'
);

Add new bookmark

A simple example of adding a bookmark to your reading list:

$link_info = array(
    'url'       => 'http://example.com'
);

$pockpack = new Pockpack($pocket_consumer_key, $pocket_access_token);
$pockpack_q = new PockpackQueue();

$pockpack_q->add($link_info);
$pockpack->send($pockpack_q);

The array that is sent to the add method can contain the following information:

  • item_id (integer; If you are overwriting a link)
  • ref_id (integer; A Twitter status id; this is used to show tweet attribution)
  • tags (array; A list of tags you want to add to this bookmark)
  • time (timestamp; This is automatically added by the PockpackQueue class)
  • title (string; An optional title if you want to control it)
  • url (string; The URL of the item)

Modify existing bookmark

The main flow to modify a bookmark is as follows

$pockpack = new Pockpack($pocket_consumer_key, $pocket_access_token);
$pockpack_q = new PockpackQueue();

$pockpack_q->favorite($item_id);

$pockpack->send($pockpack_q);

You first need to create the pockpack connection, then add something to the queue, and finally send the queue to pocket.

You can add as many items to the queue before sending, to send in bulk to keep things fast.

Archive bookmark

$pockpack_q->archive($item_id);

Re-add bookmark

$pockpack_q->readd($item_id);

Favorite bookmark

$pockpack_q->favorite($item_id);

Unfavorite bookmark

$pockpack_q->unfavorite($item_id);

Delete bookmark

$pockpack_q->delete($item_id);

Tagging Actions for bookmarks

The main flow of tagging is as follows

$pockpack = new Pockpack($pocket_consumer_key, $pocket_access_token);
$pockpack_q = new PockpackQueue();

$tags = array("sampleTag1","sampleTag2");
$tag_info = array(
    'item_id'     => $item_id,
    'tags'        => $tags
    
);

$pockpack_q->tags_add($tag_info);

$pockpack->send($pockpack_q);

Add Tags

$pockpack_q->tags_add($tag_info);

Remove Tags

$pockpack_q->tags_remove($tag_info);

Replace Tags

$pockpack_q->tags_replace($tag_info);

Clear Tags

Clear Tag does not require $tag_info but only $item_id

$pockpack_q->tags_clear($item_id);

Contributing

Contributions are encouraged and welcome; to keep things organised, all bugs and requests should be opened in the github issues tab for the main project, at duellsy/pockpack/issues

All pull requests should be made to the develop branch, so they can be tested before being merged into the master branch.

Bitdeli Badge

duellsy/pockpack 适用场景与选型建议

duellsy/pockpack 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 376 次下载、GitHub Stars 达 23, 最近一次更新时间为 2013 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「pocket」 「getpocket」 「get pocket」 「read it later」 「readitlater」 「pockpack」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 duellsy/pockpack 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 duellsy/pockpack 我们能提供哪些服务?
定制开发 / 二次开发

基于 duellsy/pockpack 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 376
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-01-24