I want to integrate Superfeedr API using PubSubHubbub in PHP. I am following this and my code is:
<?php require_once('Superfeedr.class.php') $superfeedr = new Superfeedr('http://push-pub.appspot.com/feed', 'http://mycallback.tld/push?feed=http%3A%2F%2Fpush-pub.appspot.com%2Ffeed','http://wallabee.superfeedr.com'); $superfeedr->verbose = true; $superfeedr->subscribe();?>
And my subscribe() function is
public function subscribe(){ $this->request('subscribe');}private function request($mode){ $data = array(); $data['topic'] = $this->topic; $data['callback'] = $this->callback; $post_data = array ( "hub.mode" => 'subscribe', "hub.verify" => "sync", "hub.callback" => urlencode($this->callback), "hub.topic" => urlencode($this->topic),"hub.verify_token" => "26550615cbbed86df28847cec06d3769", ); //echo "<pre>"; print_r($post_data); exit; // url-ify the data for the POST foreach ($post_data as $key=>$value) { $post_data_string .= $key.'='. $value.'&'; } rtrim($fields_string,'&'); // curl request $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->hub); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json')); curl_setopt($ch, CURLOPT_USERPWD, 'USERNAME:PASSWORD'); $output = curl_exec($ch); if ($this->verbose) { print('<pre>'); print_r($output); print('</pre>'); } }
But after execution I am getting this error
HTTP/1.1 422 Unprocessable EntityX-Powered-By: The force, LukeVary: X-HTTP-Method-Override, Accept-EncodingContent-Type: text/plain; charset=utf-8X-Superfeedr-Host: supernoder16.superfeedr.comAccess-Control-Allow-Origin: *Access-Control-Allow-Credentials: trueAccess-Control-Allow-Methods: GET, POST, PUT, DELETEAccess-Control-Allow-Headers: AuthorizationContent-Length: 97ETag: W/"61-db6269b5"Date: Wed, 24 Aug 2016 14:01:47 GMTConnection: closePlease provide a valid hub.topic (feed) URL that is accepted on this hub. The hub does not match.
Same data (topic and callback etc..) requesting from https://superfeedr.com/users/testdata/push_consoleis working fine. But I don't know why I am getting this error on my local. If anyone has any experienced with same problom then please help me. Thanks.