Question

I tried for over 10 hours to setup a Google's pubsubhubbub feed (manual + php), but it's not working. Here is what I did so far:

  1. Published 'buystreamme.blogspot.de/feeds/posts/default'

  2. visited pubsubhubbub.appspot.com/subscribe

My endpoint.php looks like this:

 <?php
    if (isset($_GET['hub_challenge'])) {
        file_put_contents('verification.txt',"verified");
        header('HTTP/1.1 204 "No Content"', true, 204);
        echo $_GET['hub_challenge'];
        exit;
    }
    else {
        $xml=file_get_contents("php://input");
        file_put_contents('endpoint.txt',$xml);
    }
 ?>

What (not) happened?

  1. endpoint.php is called after subscription and 'verification.txt' is properly created.
  2. Then calling 'Subscription Details' the state of the feed stays 'unverified'.
  3. Then creating a new post in my test blog, the callback file 'endpoint.php' isn't called (no output is created).

What am I doing wrong?

  1. The feed is a test feed, has no subscribers.
  2. The hoster is one.com, anything block the call?

Hopefully somebody can help me. I don't see the error and other search results did not help me :(

Thank you very much,

Thomas

Was it helpful?

Solution

9 hours later I found the answer ... so I want so share my thoughts if somebody has similar problems:

After reading through this post

https://groups.google.com/d/msg/pubsubhubbub/7RPlYMds4RI/2mIHQTdV3aoJ

it was clear that I have to enter some (int) number for Lease Seconds and remove all Verify Token. Also the false return HTTP code of 409 for "sync" as Verify Type is now clear as "sync" is out of date.

So all in all, i think https://pubsubhubbub.appspot.com/subscribe is just out of date.

My php solution:

<?
$secret = hash('sha1', uniqid(rand(), true));
$post_fields = array(
    'hub.callback' => 'some_php_callback_file_on_your_webspace',
    'hub.mode' => 'subscribe',
    'hub.topic' => 'your_feed', // must be equal to "self" href in feed!
    'hub.verify' => 'async',
    'hub.lease_seconds' => '300', //5 minutes subscription, than feed expires
    'hub.secret' => $secret
);

$request = curl_init('https://pubsubhubbub.appspot.com/'); // the hub
curl_setopt($request, CURLOPT_POST, TRUE);
curl_setopt($request, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt( $request, CURLOPT_VERBOSE, 1 );
curl_exec($request);
$code = curl_getinfo($request, CURLINFO_HTTP_CODE);
print_r( $code );
if (in_array($code, array(202, 204))) {
  print_r("Positive response - request ($code). - secret: $secret");
}
else {
  print_r("Error issuing - request - ($code).");
}
curl_close($request);
?>

and my callback.php file:

if (isset($_GET['hub_challenge'])) {
    print $_GET['hub_challenge'];
}
else {
    $xml=file_get_contents("php://input");
    file_put_contents('endpoint.txt',$xml);
}

Of course not the final solution, but I am happy with this first draft after 2 days :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top