Guest User

cURL mercadolivre login

a guest
Feb 7th, 2015
1,454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.71 KB | None | 0 0
  1. <?php
  2. // Create temp file to store cookies
  3. $ckfile = tempnam ("/tmp", "CURLCOOKIE");
  4.  
  5. // URL to login page
  6. $url = "https://www.mercadolivre.com/jms/mlb/lgz/login/authenticate";
  7.  
  8. // Get Login page and its cookies and save cookies in the temp file
  9. $ch = curl_init();
  10. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Accepts all CAs
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile); // Stores cookies in the temp file
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. $output = curl_exec($ch);
  15. echo '1<BR></BR>' . $output;
  16.  
  17. // Post login form and follow redirects
  18. $ch = curl_init();
  19. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Accepts all CAs
  20. curl_setopt($ch, CURLOPT_URL, $url);
  21. curl_setopt($ch, CURLOPT_POST, count($fields));
  22. curl_setopt($ch, CURLOPT_POSTFIELDS, 'user_id=XXX&password=XXX&remember_me=true&signInButton=Entrar&callback_error=https://www.mercadolivre.com/jms/mlb/lgz/login&go=http://www.mercadolivre.com.br&platform_id=ml&site_idmlb&loginType=DEFAULT&dps=54d6e5ade4b0618bdcd983d0&parent_url=&arfRedirUrl=');
  23. curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); //Uses cookies from the temp file
  24. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  25. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Tells cURL to follow redirects
  26. $output = curl_exec($ch);
  27. echo '2<BR></BR>' . $output;
  28.  
  29.  
  30. $url = "http://www.mercadolivre.com.br";
  31. $ch = curl_init();
  32. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Accepts all CAs
  33. curl_setopt($ch, CURLOPT_URL, $url);
  34. curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); //Uses cookies from the temp file
  35. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  36. $output = curl_exec($ch);
  37. echo '3<BR></BR>' . $output;
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment