curl请求 https结果不对

WBOY
Release: 2016-06-20 12:36:26
Original
970 people have browsed it

环境是 windows  wamp  php5.5

------------------------------------------
程序写法:
 $ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
//$url = 'https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=jQuery110208172749384481603_1456294051449&appid=4001&com=shentong&nu=3304810729274&vcode=&token=&_=1456294051453';
$url = 'https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=jQuery110208172749384481603_1456294051449&appid=4001&com=jd&nu=12148326312&vcode=&token=&_=1456294051453';
//$url ='https://www.jb51.net';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。
$data = curl_exec($curl);
curl_close($curl);
echo ($data);
---------------------------------------------------------------
直接在地址栏输入 :
https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=jQuery110208172749384481603_1456294051449&appid=4001&com=jd&nu=12148326312&vcode=&token=&_=1456294051453
得到结果是


两个结果不一样,查了一些信息,dll 什么的,加了也不好用。帮忙你们测一下。  解决一下,谢谢


回复讨论(解决方案)

缺少 cookie 的接收和传递



前辈我的意思是,可以直接用CURL请求  HTTPS这上地址不。  这里没有发现传递值的关系啊
就是一个请求,然后把值解析出来。 (这是个物流接口,我从网上拔下来的

或有什么更好的接口没,谢谢

$url = 'https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=jQuery110208172749384481603_1456294051449&appid=4001&com=jd&nu=12148326312&vcode=&token=&_=1456294051453';$cookie = tempnam("/tmp", "cookie");$t = parse_url($url);//先获取 cookie$curl = curl_init();curl_setopt($curl, CURLOPT_URL, "$t[scheme]://$t[host]/$t[path]");curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie);curl_exec($curl);//再获取数据$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie);$data = curl_exec($curl);curl_close($curl);//解析得到的 jsonp 数据$s = preg_replace('/^.*\((.+)\).*/', '$1', $data);print_r(json_decode($s, 1));
Copy after login
Array(    [msg] =>     [status] => 0    [data] => Array        (            [info] => Array                (                    [status] => 1                    [com] => jd                    [state] => 3                    [context] => Array                        (                            [0] => Array                                (                                    [time] => 1456304591                                    [desc] => 货物已完成配送,感谢您选择京东配送                                )                            [1] => Array                                (                                    [time] => 1456299587                                    [desc] => 配送员开始配送,请您准备收货,配送员,郭林伟,手机号,18511532257                                )                            [2] => Array                                (                                    [time] => 1456298302                                    [desc] => 货物已分配,等待配送                                )                            [3] => Array                                (                                    [time] => 1456298298                                    [desc] => 货物已到达【东大桥站】                                )                            [4] => Array                                (                                    [time] => 1456292041                                    [desc] => 货物已完成分拣,离开【北京小杜社分拣中心】                                )                            [5] => Array                                (                                    [time] => 1456291522                                    [desc] => 货物已到达【北京小杜社分拣中心】                                )                            [6] => Array                                (                                    [time] => 1456284653                                    [desc] => 货物已完成分拣,离开【北京土桥接货仓】                                )                            [7] => Array                                (                                    [time] => 1456284549                                    [desc] => 货物已交付京东快递                                )                            [8] => Array                                (                                    [time] => 1456284549                                    [desc] => 货物已到达【北京土桥接货仓】                                )                        )                    [_source_com] =>                 )            [com] => jd            [company] => Array                (                    [url] => http://www.kuaidi100.com/all/jd.shtml?from=openv                    [fullname] => 京东快递                    [shortname] => 京东                    [icon] => Array                        (                            [id] =>                             [smallurl] => https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=1807529516,3291075151&fm=58                            [smallpos] => 0,1504                            [middleurl] => https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1835223070,3312272045&fm=58                            [middlepos] => 0,900                            [normal] => https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=2992147315,359626353&fm=58                        )                    [website] => Array                        (                            [title] => www.jd-ex.com                            [url] => http://www.jd-ex.com/                        )                    [tel] => 400-603-3600                    [auxiliary] => Array                        (                            [0] => Array                                (                                    [title] => 运费查询                                    [url] => http://jd-ex.com/#searchFreight                                )                            [1] => Array                                (                                    [title] => 禁运规则                                    [url] => http://jd-ex.com/forbid.html                                )                        )                )            [source] => Array                (                    [logo] => https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=1429564979,1787167512&fm=58                    [title] => 数据来自快递100                    [url] => http://www.kuaidi100.com/                    [name] => 快递100                )        ))
Copy after login

Copy after login



thanks
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template