Superfeedr响应不在laravel工作

时间:2016-08-31 07:24:34

标签: php laravel-5.1 superfeedr

我想使用PubSubHubbub api从superfeedr.com检索提要,但我的回调响应不起作用。我无法联系到我的回调。这是我的代码

class Superfeedr
{
    private $topic;
    private $callback;
    private $hub = 'http://superfeedr.com/hubbub';
    public $verbose = false;

    function __construct($topic, $callback, $hub='')
    {
        $this->topic = $topic;
        $this->callback = $callback;
        if ($hub) {
            $this->hub = $hub;
        }
    }

    public function request($mode)
    {

        $post_data = array ( 
            'hub.mode'  => 'retrieve',
            'hub.callback'  => urlencode($this->callback),
            'hub.topic' => urlencode($this->topic)
        ); 


        foreach ($post_data as $key=>$value) { 
            $post_data_string .= $key.'='. $value.'&'; 
        } 


        $url =$this->hub .'?'.$post_data_string;

        $ch = curl_init(); 

        curl_setopt($ch, CURLOPT_URL, $url); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
        curl_setopt($ch, CURLOPT_USERPWD, 'testdata:1234');
        curl_setopt($ch, CURLOPT_BUFFERSIZE, 4096);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 25);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        $output = curl_exec($ch);
    }   
}

我的php文件是

  #Retrieve.php

  $superfeedr = new Superfeedr('http://feeds.bbci.co.uk/news/world/asia/rss.xml', 
                        'mydomainurl.com/callback', 
                        'https://push.superfeedr.com');

  $superfeedr->verbose = true;
  $data = $superfeedr->request('list');

我想通知你,我的回调网址是我的一个laravel动作。这是

public function callback(Request $request)
{
    \Log::info("Testing before callback");
    if(isset($_Get["hub_challenge"])){
       echo $_Get["hub_challenge"];
       return;
    }

    // Just for testing
    \DB::table('test')->insert(['name' => "Test callback data. Please ignore"]);

}

但我的日志文件和数据库也没有任何反应。有人有任何想法,请告诉我这里有什么不对。感谢。

0 个答案:

没有答案