Advertisement
Guest User

хуйня с CURL

a guest
Apr 1st, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. $username = 'user';
  2. $password = 'pass';
  3. $loginUrl = 'http://somewebsite.com/login/';
  4.  
  5. $ch = curl_init();
  6.  
  7. curl_setopt($ch, CURLOPT_URL, $loginUrl);
  8.  
  9. curl_setopt($ch, CURLOPT_POST, 1);
  10.  
  11. curl_setopt($ch, CURLOPT_POSTFIELDS, 'uname='.$username.'&shipping=1&sum=&upass='.$password); //тук виж form-a кви скрити полета и т.н. има - трябва да изпращаш всички полета, които имат и те!
  12.  
  13. curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  14.  
  15. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  16.  
  17. curl_setopt($ch, CURLOPT_USERAGENT,
  18. "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
  19.  
  20. $store = curl_exec($ch);
  21.  
  22. //тук отваряме url-а, който ти е protected content-a
  23. curl_setopt($ch, CURLOPT_URL, 'http://somewebsite.com/protectedContent');
  24.  
  25. //execute the request
  26. $content = curl_exec($ch);
  27. echo $content; //protected huinq data
  28. curl_close($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement