1

I was implementing PubSubHubBub in kohana project. This is my subscribing code:

   public function action_curl_home()
   {
    $secret = hash('sha1', uniqid(rand(), true));
      $post_fields = array("hub.callback" => "my callback function",
        "hub.mode" => "subscribe",
        "hub.topic" => "http://feeds.feedburner.com/NdtvNews-TopStories",
        "hub.verify" => "async",
        "hub.lease_seconds" => "42800",
        "hub.secret" => $secret
    );

    $curl = curl_init("http://pubsubhubbub.appspot.com/");
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_fields);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_VERBOSE, 1);
    curl_exec($curl);
    $code = curl_getinfo($curl, 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($curl);
    exit;
}

And callback function is here:

    if (isset($_GET['hub_challenge'])) {
        print $_GET['hub_challenge'];
        file_put_contents($_SERVER['DOCUMENT_ROOT'] . "application/classes/controller/curl.txt", implode(" , ", $_GET));
        exit;
    }
    else {
        $xml=file_get_contents("php://input");
        file_put_contents($_SERVER['DOCUMENT_ROOT'] . "application/classes/controller/curl.txt", date('d-m-y h:i:s a') . $xml, FILE_APPEND);
        exit;
    }

When i am calling action_url_home() function its calling my callback function successfully. From there i don't know how to make verification. Please someone help from here

Sivabalan
  • 971
  • 2
  • 18
  • 43

1 Answers1

3

I think there is a misunderstanding when it comes to the hub.callback param. It should not be a function, but rather a webhook: a URL that is called by the hub (not you) when you issue your susbcription request.

Check this article for more details.

Julien Genestoux
  • 31,046
  • 20
  • 66
  • 93
  • a function can handle processing that's why i put as callback. I already studied that article. No luck – Sivabalan Jul 15 '15 at 11:36
  • The "callback" is a URL that is "called" by the PubSubHubbub Hub, so you have to provide the code of your "my callback function" under a different URL. Perhaps this helps: http://josephsmarr.com/2010/03/01/implementing-pubsubhubbub-subscriber-support-a-step-by-step-guide/ – Matthias Pfefferle Jul 16 '15 at 09:53
  • Thanks you guys. I don't know whats happened but hub was working fine. – Sivabalan Jul 16 '15 at 12:30