public function PuSHSubscriber::verifyRequest in Feeds 6
Same name and namespace in other branches
- 7.2 libraries/PuSHSubscriber.inc \PuSHSubscriber::verifyRequest()
- 7 libraries/PuSHSubscriber.inc \PuSHSubscriber::verifyRequest()
Verify a request. After a hub has received a subscribe or unsubscribe request (see PuSHSubscriber::request()) it sends back a challenge verifying that an action indeed was requested ($_GET['hub_challenge']). This method handles the challenge.
1 call to PuSHSubscriber::verifyRequest()
- PuSHSubscriber::handleRequest in libraries/
PuSHSubscriber.inc - Request handler for subscription callbacks.
File
- libraries/
PuSHSubscriber.inc, line 185 - Pubsubhubbub subscriber library.
Class
- PuSHSubscriber
- PubSubHubbub subscriber.
Code
public function verifyRequest() {
if (isset($_GET['hub_challenge'])) {
/**
* If a subscription is present, compare the verify token. If the token
* matches, set the status on the subscription record and confirm
* positive.
*
* If we cannot find a matching subscription and the hub checks on
* 'unsubscribe' confirm positive.
*
* In all other cases confirm negative.
*/
if ($sub = $this
->subscription()) {
if ($_GET['hub_verify_token'] == $sub->post_fields['hub.verify_token']) {
if ($_GET['hub_mode'] == 'subscribe' && $sub->status == 'subscribe') {
$sub->status = 'subscribed';
$sub->post_fields = array();
$sub
->save();
$this
->log('Verified "subscribe" request.');
$verify = TRUE;
}
elseif ($_GET['hub_mode'] == 'unsubscribe' && $sub->status == 'unsubscribe') {
$sub->status = 'unsubscribed';
$sub->post_fields = array();
$sub
->save();
$this
->log('Verified "unsubscribe" request.');
$verify = TRUE;
}
}
}
elseif ($_GET['hub_mode'] == 'unsubscribe') {
$this
->log('Verified "unsubscribe" request.');
$verify = TRUE;
}
if ($verify) {
header('HTTP/1.1 200 "Found"', NULL, 200);
print $_GET['hub_challenge'];
exit;
}
}
header('HTTP/1.1 404 "Not Found"', NULL, 404);
$this
->log('Could not verify subscription.', 'error');
exit;
}