Advertisement
Guest User

Untitled

a guest
Oct 12th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. > > function curlPost($postUrl, $postFields) {
  2. >
  3. > $cookie = 'cookie.txt'; // Setting a cookie file to store cookie
  4. >
  5. > $ch = curl_init(); // Initialising cURL session
  6. >
  7. > // Setting cURL options
  8. > curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // Prevent cURL from verifying SSL certificate
  9. > curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); // Script should fail silently on error
  10. > curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE); // Use cookies
  11. > curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // Follow Location: headers
  12. > curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Returning transfer as a string
  13. > curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); // Setting cookiefile
  14. > curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); // Setting cookiejar
  15. > curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre
  16. > ThunderBrowse/3.2.1.8"); // Setting useragent
  17. >
  18. > curl_setopt($ch, CURLOPT_URL, $postUrl); // Setting URL to POST to
  19. > curl_setopt($ch, CURLOPT_POST, TRUE); // Setting method as POST
  20. >
  21. > curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields)); // Setting POST fields as array
  22. >
  23. > $results = curl_exec($ch); // Executing cURL session
  24. > curl_close($ch); // Closing cURL session
  25. >
  26. > return $results;
  27. > }
  28.  
  29. > > $user ="userxxx";
  30. > $pass = "passxxxxxxx";
  31. >
  32. >
  33. > $login_url = "http://www.xxxxx.com/repositorio/consultas_web/";
  34. > $post_array = array ('login' => $user,
  35. > 'password' => $pass); // Building post array.
  36. >
  37. >
  38. > $results = curlPost($login_url, $post_array);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement