(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.