public function Callback::handle in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/zendframework/zend-feed/src/PubSubHubbub/Subscriber/Callback.php \Zend\Feed\PubSubHubbub\Subscriber\Callback::handle()
Handle any callback from a Hub Server responding to a subscription or unsubscription request. This should be the Hub Server confirming the the request prior to taking action on it.
Parameters
array $httpGetData GET data if available and not in $_GET:
bool $sendResponseNow Whether to send response now or when asked:
Return value
void
File
- vendor/
zendframework/ zend-feed/ src/ PubSubHubbub/ Subscriber/ Callback.php, line 64
Class
Namespace
Zend\Feed\PubSubHubbub\SubscriberCode
public function handle(array $httpGetData = null, $sendResponseNow = false) {
if ($httpGetData === null) {
$httpGetData = $_GET;
}
/**
* Handle any feed updates (sorry for the mess :P)
*
* This DOES NOT attempt to process a feed update. Feed updates
* SHOULD be validated/processed by an asynchronous process so as
* to avoid holding up responses to the Hub.
*/
$contentType = $this
->_getHeader('Content-Type');
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post' && $this
->_hasValidVerifyToken(null, false) && (stripos($contentType, 'application/atom+xml') === 0 || stripos($contentType, 'application/rss+xml') === 0 || stripos($contentType, 'application/xml') === 0 || stripos($contentType, 'text/xml') === 0 || stripos($contentType, 'application/rdf+xml') === 0)) {
$this
->setFeedUpdate($this
->_getRawBody());
$this
->getHttpResponse()
->setHeader('X-Hub-On-Behalf-Of', $this
->getSubscriberCount());
/**
* Handle any (un)subscribe confirmation requests
*/
}
elseif ($this
->isValidHubVerification($httpGetData)) {
$this
->getHttpResponse()
->setContent($httpGetData['hub_challenge']);
switch (strtolower($httpGetData['hub_mode'])) {
case 'subscribe':
$data = $this->currentSubscriptionData;
$data['subscription_state'] = PubSubHubbub\PubSubHubbub::SUBSCRIPTION_VERIFIED;
if (isset($httpGetData['hub_lease_seconds'])) {
$data['lease_seconds'] = $httpGetData['hub_lease_seconds'];
}
$this
->getStorage()
->setSubscription($data);
break;
case 'unsubscribe':
$verifyTokenKey = $this
->_detectVerifyTokenKey($httpGetData);
$this
->getStorage()
->deleteSubscription($verifyTokenKey);
break;
default:
throw new Exception\RuntimeException(sprintf('Invalid hub_mode ("%s") provided', $httpGetData['hub_mode']));
}
/**
* Hey, C'mon! We tried everything else!
*/
}
else {
$this
->getHttpResponse()
->setStatusCode(404);
}
if ($sendResponseNow) {
$this
->sendResponse();
}
}