Curl obtains verification code remotely
$CookieFile=tempnam("./tmep","beast"); if(isset($_GET["img"])){ $url = 'http://www .yto.net.cn/Controller/ValidateCode.aspx';//Verification code code $ch = curl_init($url); curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);//Save the returned cookie information In the file curl_exec($ch); curl_close($ch); exit(); } if(isset($_POST['d'])){ $b=$_POST[d];/ /Verification code $p="waybillNo=1721269381&inputcode=".$b; $ch = curl_init(); // 2. Set options, including URL curl_setopt($ch,CURLOPT_URL, "http://jingang. yto56.com.cn/expws/expquery/waybillService.action"); curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile); curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//Send Cookie at the same time curl_setopt($ch ,CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//Submit query information $s = curl_exec($ch); curl_close($ch) ; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, "http://jingang.yto56.com.cn/expws/expquery/waybillService.action"); curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile ) ;/ Send cookie curl_Setopt ($ ch, curlopt_cookiejar, $ cookiefile); , Curlopt_post, 1); CURL_SETOPT ($ ch, curlopt_postfields, $ p);//Submit query information $bs = curl_exec($ch); echo $bs;//Output results curl_close($ch); }else{ ?>
?>
Copy code