Rumah  >  Artikel  >  pembangunan bahagian belakang  >  curl cookiejar 获取不到内容,该怎么解决

curl cookiejar 获取不到内容,该怎么解决

WBOY
WBOYasal
2016-06-13 12:08:221443semak imbas

curl cookiejar 获取不到内容

<?php<br /><br />curlImage();<br />function curlImage(){<br />    $cookieJar=tempnam('tmp', cookieImage);<br />    $ch=curl_init("http://124.160.104.166/(1jovmraaf1pemj55dkr01ebo)/CheckCode.aspx");<br />    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieJar);<br />    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />    $image=curl_exec($ch);<br />    curl_close($ch);<br />    $fp=fopen("image.gif", "w+");<br />    fwrite($fp, $image);<br /><br />}<br />






这段代码是获取验证码加上cookie得可是每次看cookieImage文件都是空得
这是为什么?[yabao=][/yabao][yabao=][/yabao]

------解决思路----------------------
print_r(get_headers('http://124.160.104.166/'));
Array<br />(<br />    [0] => HTTP/1.1 302 Found<br />    [1] => Connection: close<br />    [2] => Date: Thu, 02 Oct 2014 03:05:03 GMT<br />    [3] => Server: Microsoft-IIS/6.0<br />    [4] => X-Powered-By: ASP.NET<br />    [5] => X-AspNet-Version: 1.1.4322<br />    [6] => Location: /(mggxrgvmym2tzn45b5wfkh55)/default2.aspx<br />    [7] => Cache-Control: private<br />    [8] => Content-Type: text/html; charset=gb2312<br />    [9] => Content-Length: 158<br />    [10] => HTTP/1.1 200 OK<br />    [11] => Connection: close<br />    [12] => Date: Thu, 02 Oct 2014 03:05:04 GMT<br />    [13] => Server: Microsoft-IIS/6.0<br />    [14] => X-Powered-By: ASP.NET<br />    [15] => X-AspNet-Version: 1.1.4322<br />    [16] => Pragma: no-cache<br />    [17] => Cache-Control: no-cache<br />    [18] => Pragma: no-cache<br />    [19] => Expires: -1<br />    [20] => Content-Type: text/html; charset=gb2312<br />    [21] => Content-Length: 4091<br />)<br /><br />
显然跳转中的形如 (mggxrgvmym2tzn45b5wfkh55) 的路径是充当 session 的角色的
------解决思路----------------------
顶上说的对啊

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn