Micah Nordland b4f19faca8 | 3 years ago | |
---|---|---|
src/p3k/WebSub | 3 years ago | |
.gitignore | 7 years ago | |
CONTRIBUTING.md | 7 years ago | |
LICENSE | 7 years ago | |
README.md | 7 years ago | |
composer.json | 7 years ago |
$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);
// Returns false unless both hub and self were found
$endpoints = $client->discover($topic);
// $endpoints['hub']
// $endpoints['self']
$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
]);
$signature = $_SERVER['HTTP_X_HUB_SIGNATURE'];
$document = file_get_contents('php://input');
$valid = p3k\WebSub\Client::verify_signature($document, $signature, $secret);
Copyright 2017 by Aaron Parecki
Available under the MIT license.