Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
Aaron Parecki 3e37fbb3e8
send post body as form-encoded
před 6 roky
src/p3k/WebSub send post body as form-encoded před 6 roky
.gitignore first commit of helper functions for writing a WebSub client před 7 roky
CONTRIBUTING.md first commit of helper functions for writing a WebSub client před 7 roky
LICENSE first commit of helper functions for writing a WebSub client před 7 roky
README.md first commit of helper functions for writing a WebSub client před 7 roky
composer.json first commit of helper functions for writing a WebSub client před 7 roky

README.md

p3k-websub

Usage

Initialize the client

$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

// Returns false unless both hub and self were found
$endpoints = $client->discover($topic);

// $endpoints['hub'] 
// $endpoints['self'] 

Send the subscription request

$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

$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.