Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaronpk/p3k-websub
A library for subscribing to and publishing WebSub feeds
https://github.com/aaronpk/p3k-websub
indieweb p3k pubsubhubbub websub
Last synced: 5 days ago
JSON representation
A library for subscribing to and publishing WebSub feeds
- Host: GitHub
- URL: https://github.com/aaronpk/p3k-websub
- Owner: aaronpk
- License: mit
- Created: 2017-05-01T19:29:34.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-07T14:55:03.000Z (over 3 years ago)
- Last Synced: 2024-10-06T19:49:20.388Z (about 1 month ago)
- Topics: indieweb, p3k, pubsubhubbub, websub
- Language: PHP
- Homepage:
- Size: 3.91 KB
- Stars: 7
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# p3k-websub
## Usage
### Initialize the client
```php
$http = new p3k\HTTP('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) p3k-websub/0.1.0 example');
$client = new p3k\WebSub\Client($http);
```### Discover the hub and self URLs for a topic URL
```php
// Returns false unless both hub and self were found
$endpoints = $client->discover($topic);// $endpoints['hub']
// $endpoints['self']
```### Send the subscription request
```php
$secret = p3k\random_string(32);
$id = p3k\random_string(32);
$callback = 'http://localhost:8080/subscriber.php?id='.$id;$subscription = $client->subscribe($endpoints['hub'], $endpoints['self'], $callback, [
'lease_seconds' => 300,
'secret' => $secret
]);
```### Verify the signature
```php
$signature = $_SERVER['HTTP_X_HUB_SIGNATURE'];
$document = file_get_contents('php://input');
$valid = p3k\WebSub\Client::verify_signature($document, $signature, $secret);
```## License
Copyright 2017 by Aaron Parecki
Available under the MIT license.