Curl obtains verification code remotely

WBOY
Release: 2016-07-25 09:08:38
Original
1925 people have browsed it
Curl obtains verification code remotely
  1. $CookieFile=tempnam("./tmep","beast");
  2. if(isset($_GET["img"])){
  3. $url = 'http://www .yto.net.cn/Controller/ValidateCode.aspx';//Verification code code
  4. $ch = curl_init($url);
  5. curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);//Save the returned cookie information In the file
  6. curl_exec($ch);
  7. curl_close($ch);
  8. exit();
  9. }
  10. if(isset($_POST['d'])){
  11. $b=$_POST[d];/ /Verification code
  12. $p="waybillNo=1721269381&inputcode=".$b;
  13. $ch = curl_init();
  14. // 2. Set options, including URL
  15. curl_setopt($ch,CURLOPT_URL, "http://jingang. yto56.com.cn/expws/expquery/waybillService.action");
  16. curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
  17. curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//Send Cookie at the same time
  18. curl_setopt($ch ,CURLOPT_RETURNTRANSFER, 1);
  19. curl_setopt($ch,CURLOPT_POST, 1);
  20. curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//Submit query information
  21. $s = curl_exec($ch);
  22. curl_close($ch) ;
  23. $ch = curl_init();
  24. curl_setopt($ch,CURLOPT_URL, "http://jingang.yto56.com.cn/expws/expquery/waybillService.action");
  25. curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile ) ;/ Send cookie
  26. curl_Setopt ($ ch, curlopt_cookiejar, $ cookiefile); , Curlopt_post, 1);
  27. CURL_SETOPT ($ ch, curlopt_postfields, $ p);//Submit query information
  28. $bs = curl_exec($ch);
  29. echo $bs;//Output results
  30. curl_close($ch);
  31. }else{
  32. ?>
  33. ?>
Copy code
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!