Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > > function curlPost($postUrl, $postFields) {
- >
- > $cookie = 'cookie.txt'; // Setting a cookie file to store cookie
- >
- > $ch = curl_init(); // Initialising cURL session
- >
- > // Setting cURL options
- > curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // Prevent cURL from verifying SSL certificate
- > curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); // Script should fail silently on error
- > curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE); // Use cookies
- > curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // Follow Location: headers
- > curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Returning transfer as a string
- > curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); // Setting cookiefile
- > curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); // Setting cookiejar
- > curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre
- > ThunderBrowse/3.2.1.8"); // Setting useragent
- >
- > curl_setopt($ch, CURLOPT_URL, $postUrl); // Setting URL to POST to
- > curl_setopt($ch, CURLOPT_POST, TRUE); // Setting method as POST
- >
- > curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields)); // Setting POST fields as array
- >
- > $results = curl_exec($ch); // Executing cURL session
- > curl_close($ch); // Closing cURL session
- >
- > return $results;
- > }
- > > $user ="userxxx";
- > $pass = "passxxxxxxx";
- >
- >
- > $login_url = "http://www.xxxxx.com/repositorio/consultas_web/";
- > $post_array = array ('login' => $user,
- > 'password' => $pass); // Building post array.
- >
- >
- > $results = curlPost($login_url, $post_array);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement