PHP Curl Simulation Login to the square educational system example

Source: Internet
Author: User
  1. $url = ";//Square Educational system login Address
  2. $ID = ";
  3. $PA = ";
  4. $cookieid = Get_sessionid ($url);//Get the session ID of the login page
  5. /*
  6. Is_login () function to determine if the login was successful
  7. */
  8. function Is_login ()
  9. {
  10. Global $url, $ID, $PA, $cookieid;
  11. Preg_match (' #value = ' ([^ ']+) ' # ', Curl_get ($url), $VI);
  12. $p = ' __viewstate= '. UrlEncode ($vi [1]). ' &tbyhm= '. $ID. ' &tbpsw= '. $PA. ' &ddlsf=%d1%a7%c9%fa&imgdl.x=39&imgdl.y=13 '; Default Student
  13. $co = Curl_get ($url, $p, 0, 0, 0, array (' cookie:asp.net_sessionid= '. $cookieid));
  14. Curl_get (' Address/xsleft.aspx?flag=grxx ', array (' cookie:asp.net_sessionid= '. $cookieid)); This address must be accessed before obtaining basic information
  15. Return Strpos ($co, "/xsmainfs.aspx?xh=". $ID)? True:false;
  16. }//Bbs.it-home.org
  17. function Curl_get ($url, $add _arry_header = 0)
  18. {
  19. $ch = Curl_init ($url);
  20. curl_setopt ($ch, Curlopt_httpheader, Array (' user-agent:mozilla/5.0 (iPhone; U CPU iPhone os 3_1_2 like Mac os X; En-US) applewebkit/528.18 (khtml, like Gecko) version/4.0 mobile/7d11 safari/528.16 '));
  21. if ($add _arry_header)
  22. {
  23. curl_setopt ($ch, Curlopt_httpheader, $add _arry_header);
  24. }
  25. curl_setopt ($ch, Curlopt_returntransfer, true);
  26. $get _url = curl_exec ($ch);
  27. Curl_close ($ch);
  28. return $get _url;
  29. }
  30. function Get_sessionid ($u)//Get the session ID of ASPX
  31. {
  32. $a = get_headers ($u);
  33. $a = str_replace (Array ('; ', ': '), ' & ', $a [6]);
  34. Parse_str ($a, $AA);
  35. return $AA [' Asp_net_sessionid '];
  36. }
  37. ?>
Copy Code

Description: Code is not fully available, just reference, record. The login address of the square educational system also has the default4.aspx thin login box, the simulation should be simpler.

>>> more PHP Demo login articles, featured links: PHP Emulation login PHP Curl Demo Login Tutorial Daquan

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.