curesaba/php-subscriber
Composer 安装命令:
composer require curesaba/php-subscriber
包简介
A PHP client library implementing a PubSubHubbub (WebSub) subscriber with hub.secret support.
README 文档
README
This PHP library implements a subscriber for PubSubHubbub (WebSub) with support for the hub.secret parameter for secure HMAC signature verification and flexible configuration options including verify_token.
Originally written by Josh Fraser and currently maintained by CureSaba.
Released under the Apache 2.0 License.
Official package: pubsubhubbub/subscriber
Maintained fork: curesaba/php-subscriber
Install
Update your composer require block:
"require": { "curesaba/php-subscriber": "*" }
Or install via Composer:
composer require curesaba/php-subscriber
Usage
use \Pubsubhubbub\Subscriber\Subscriber; $hub_url = "http://pubsubhubbub.appspot.com"; $callback_url = "https://yourdomain.example/endpoint"; $secret = "your-very-random-string"; // Used for HMAC verification $verify_token = "your-verify-token"; // Used to validate intent verification requests // create a new subscriber with flexible options (all parameters optional except hub_url and callback_url) $s = new Subscriber( $hub_url, $callback_url, false, // credentials (optional) $secret, // hub.secret (optional) 'async', // verify mode (optional, default 'async') $verify_token, // verify_token (optional) 3600 // lease_seconds (optional) ); $feed = "http://feeds.feedburner.com/onlineaspect"; // subscribe to a feed $s->subscribe($feed); // unsubscribe from a feed $s->unsubscribe($feed); // You can also set properties after construction: $s->setVerifyToken('another-token')->setLeaseSeconds(7200);
Parameters
- $hub_url: The PubSubHubbub (WebSub) hub endpoint. (Required)
- $callback_url: Your endpoint to receive notifications. (Required)
- $credentials: (Optional) HTTP Basic Auth credentials for the hub.
- $secret: (Optional but recommended) Secret string for verifying HMAC signatures (
hub.secret). - $verify: (Optional) Verification mode
"async"or"sync". Default:"async". - $verify_token: (Optional) Token for intent verification.
- $lease_seconds: (Optional) Subscription lease duration in seconds.
Property Setters
All parameters (except $google_key) can also be set or changed after instantiation using the following setter methods:
setHubUrl($hub_url)setCallbackUrl($callback_url)setCredentials($credentials)setSecret($secret)setVerify($verify)setVerifyToken($verify_token)setLeaseSeconds($lease_seconds)
HMAC Signature Verification
When using hub.secret, notifications sent from the hub will include an X-Hub-Signature header.
You should verify this in your callback endpoint:
$body = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_HUB_SIGNATURE'] ?? ''; $expected = 'sha1=' . hash_hmac('sha1', $body, $secret); if (hash_equals($expected, $signature)) { // Signature valid } else { // Signature invalid }
License
Apache License 2.0
curesaba/php-subscriber 适用场景与选型建议
curesaba/php-subscriber 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 06 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「data」 「feeds」 「pubsubhubbub」 「subscriber」 「websub」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 curesaba/php-subscriber 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 curesaba/php-subscriber 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 curesaba/php-subscriber 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
pubsubhubbub implementation of subscriber.
Amazon Marketplace Web Service Feeds API - PHP for managing listings and items with Amazon market place.
A library for subscribing to and publishing WebSub feeds
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2025-06-05