2

I'm trying to use Pubsubhubub to get real time RSS feeds update. I'm using PHP for that purpose.

I subscribed to thenextweb as an example;

$hub_url = "http://pubsubhubbub.appspot.com/";
$callback_url = "http://xx.com/rss/callback.php";
$feed = "http://feeds2.feedburner.com/thenextweb";
$sub = new Subscriber($hub_url, $callback_url);
$status = $sub->subscribe($feed);

I receive The hub returns code 202, and after that a "GET" response to my callback.php with the hub_challenge and other stuff. I followed what the tutorials suggest of echoing this number, and hence, the hub will be able to push updates to my callback.

if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe') { 
$challenge = $_GET['hub_challenge'];
header('HTTP/1.1 200 "OK"', null, 200);
header('Content-Type: text/plain');
echo $challenge;
}

That's how I echo the challenge number. The problem here is that I don't get any other messages from the hub even though i have a condition to handle any POST message in my callback.

else if ($method == 'POST') {
$updates = json_decode(file_get_contents("php://input"), true);
//doing stuff with the data here
}

I'm not sure if the problem is with the echo part or after that. Does anyone have similar issues? what am I doing wrong?

  • Try to remove the `json_decode` of the post handler. You should receive a atom/rss entry, so this might be a problem. – Matthias Pfefferle Dec 09 '14 at 15:02
  • The thing is that my callback.php is never called again. Before these conditions, I have a piece of code that saves the time when callback.php is called, and after the first "get", nothing happens. – Abed Elaziz Shehadeh Dec 10 '14 at 00:43

1 Answers1

1

I just solved the problem. Apparently I was using a different topic_url, I was using this link: http://feeds.feedburner.com/TheBoyGeniusReport?format=xml. Instead, view the page source and make sure you are using the link inside href. The highlighted link below is what you're supposed to use.

... xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TheBoyGeniusReport"...