protected function Subscriber::_getRequestParameters in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-feed/src/PubSubHubbub/Subscriber.php \Zend\Feed\PubSubHubbub\Subscriber::_getRequestParameters()
Return a list of standard protocol/optional parameters for addition to client's POST body that are specific to the current Hub Server URL
Parameters
string $hubUrl:
string $mode:
Return value
string
Throws
Exception\InvalidArgumentException
1 call to Subscriber::_getRequestParameters()
- Subscriber::_doRequest in vendor/
zendframework/ zend-feed/ src/ PubSubHubbub/ Subscriber.php - Executes an (un)subscribe request
File
- vendor/
zendframework/ zend-feed/ src/ PubSubHubbub/ Subscriber.php, line 669
Class
Namespace
Zend\Feed\PubSubHubbubCode
protected function _getRequestParameters($hubUrl, $mode) {
if (!in_array($mode, [
'subscribe',
'unsubscribe',
])) {
throw new Exception\InvalidArgumentException('Invalid mode specified: "' . $mode . '" which should have been "subscribe" or "unsubscribe"');
}
$params = [
'hub.mode' => $mode,
'hub.topic' => $this
->getTopicUrl(),
];
if ($this
->getPreferredVerificationMode() == PubSubHubbub::VERIFICATION_MODE_SYNC) {
$vmodes = [
PubSubHubbub::VERIFICATION_MODE_SYNC,
PubSubHubbub::VERIFICATION_MODE_ASYNC,
];
}
else {
$vmodes = [
PubSubHubbub::VERIFICATION_MODE_ASYNC,
PubSubHubbub::VERIFICATION_MODE_SYNC,
];
}
$params['hub.verify'] = [];
foreach ($vmodes as $vmode) {
$params['hub.verify'][] = $vmode;
}
/**
* Establish a persistent verify_token and attach key to callback
* URL's path/query_string
*/
$key = $this
->_generateSubscriptionKey($params, $hubUrl);
$token = $this
->_generateVerifyToken();
$params['hub.verify_token'] = $token;
// Note: query string only usable with PuSH 0.2 Hubs
if (!$this->usePathParameter) {
$params['hub.callback'] = $this
->getCallbackUrl() . '?xhub.subscription=' . PubSubHubbub::urlencode($key);
}
else {
$params['hub.callback'] = rtrim($this
->getCallbackUrl(), '/') . '/' . PubSubHubbub::urlencode($key);
}
if ($mode == 'subscribe' && $this
->getLeaseSeconds() !== null) {
$params['hub.lease_seconds'] = $this
->getLeaseSeconds();
}
// hub.secret not currently supported
$optParams = $this
->getParameters();
foreach ($optParams as $name => $value) {
$params[$name] = $value;
}
// store subscription to storage
$now = new DateTime();
$expires = null;
if (isset($params['hub.lease_seconds'])) {
$expires = $now
->add(new DateInterval('PT' . $params['hub.lease_seconds'] . 'S'))
->format('Y-m-d H:i:s');
}
$data = [
'id' => $key,
'topic_url' => $params['hub.topic'],
'hub_url' => $hubUrl,
'created_time' => $now
->format('Y-m-d H:i:s'),
'lease_seconds' => $params['hub.lease_seconds'],
'verify_token' => hash('sha256', $params['hub.verify_token']),
'secret' => null,
'expiration_time' => $expires,
'subscription_state' => $mode == 'unsubscribe' ? PubSubHubbub::SUBSCRIPTION_TODELETE : PubSubHubbub::SUBSCRIPTION_NOTVERIFIED,
];
$this
->getStorage()
->setSubscription($data);
return $this
->_toByteValueOrderedString($this
->_urlEncode($params));
}