(Great God) Php Curl Verification Code impersonation login related issues

Source: Internet
Author: User
(Help the Great God) PHP Curl Verification Code Simulation login problem

function Curllogin ($login _url, $cookieFile _code, $cookieFile _login, $loginParams, $target _url)
$ch = Curl_init ($login _url);
curl_setopt ($ch, Curlopt_cookiefile, $cookieFile _code); Verification Code Session Value upload
curl_setopt ($ch, Curlopt_cookiejar, $cookieFile _login); Get Login Cookie
curl_setopt ($ch, Curlopt_header, 1);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_postfields, $loginParams); Submit Query Information
Curl_exec ($ch);
Curl_close ($ch);
$ch = Curl_init ($target _url);
curl_setopt ($ch, Curlopt_cookiefile, $cookieFile _login);
curl_setopt ($ch, Curlopt_returntransfer, 1);
$content = curl_exec ($ch);
if (Curl_errno ($ch)) {
Return Curl_error ($ch);
Curl_close ($ch);
return $content;

I am trying to impersonate a website with a verification code, verification Code I use a manual identification method, in the local stored session value of the cookie and manually recognized verification code after the login, I want to get the cookie to remain logged in, but the access to the verification code of the cookie, I use the following two lines of code, please God for me to answer how to modify it?

curl_setopt ($ch, Curlopt_cookiefile, $cookieFile _code); Verification Code Session Value upload
curl_setopt ($ch, Curlopt_cookiejar, $cookieFile _login); Get a cookie that keeps you signed in

------to solve the idea----------------------
To take two steps, first get the verification code of the cookies,
Then submit the cookies after the login.
------to solve the idea----------------------
Did you follow the steps? (You just give a function that doesn't explain anything)
1. Access the form page (SessionID may be here)
2, read the verification code image to the recognition form
3, receive the submitted verification code data
4. Submit comprehensive data to the form target page

In addition to 3, each step must have
curl_setopt ($ch, Curlopt_cookiefile, $cookieFile _code);
curl_setopt ($ch, Curlopt_cookiejar, $cookieFile _login);

Obviously, these jobs are impossible to do in a function.
In spite of good writing, you can use only one function, but it must be called multiple times.
  • Related Article

    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.