get方式:

   set_time_limit(0);
        $url ='http://xxxxxxxx?pwd=wJ2312&s=1&e=2&d=1&t=asc&type=movie';
        $ch = curl_init ();
        curl_setopt ($ch,CURLOPT_URL, $url );
        curl_setopt ($ch,CURLOPT_HTTPHEADER,0);
        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        $html = curl_exec($ch);
        curl_close ( $ch );

        $json = json_decode($html);
        //print_r($json[0]->{'title2'});
        print_r($json);

post方式:

 set_time_limit(0);
        $url ='http://XXXXXXX';
        $data=array(
            'pwd'=>'wJ2312',
            's'=>1,
            'e'=>1,
            'd'=>1,
            't'=>'asc',
            'type'=>'schedule'
        );
        $ch = curl_init ();
        curl_setopt ( $ch, CURLOPT_URL, $url );
        curl_setopt ( $ch, CURLOPT_POST, 1 );
        curl_setopt ( $ch, CURLOPT_HEADER, 0 );
        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );
        $html = curl_exec ( $ch );
        curl_close ( $ch );
        $json = json_decode($html);
        //print_r($json[0]->{'title2'});
        print_r($json);

在做这个是时候 服务器那边也是自己写的,加载一些其它的php文件,页面打印有数据 ,但是转为json没有数据 ,这时在服务器输出 之前加上ob_clean();就可以拿到数据 了。

 

posted on 2016-03-22 15:09  allen817  阅读(110)  评论(0编辑  收藏  举报