Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] curl_setopt i logowanie
Krizis
post
Post #1





Grupa: Zarejestrowani
Postów: 49
Pomógł: 1
Dołączył: 27.07.2008

Ostrzeżenie: (0%)
-----


Witam biggrin.gif
Posiadam oto taki kod:
  1. <?php
  2.  
  3. function cURL_POST($url,$data)
  4. {
  5. $ch = curl_init();
  6. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3');
  7. curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
  8. curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
  9. curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  10. curl_setopt($ch, CURLOPT_URL,$url);
  11. curl_setopt($ch, CURLOPT_HEADER, false);
  12. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
  14. curl_setopt($ch, CURLOPT_POST, 1);
  15. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  16. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  17.  
  18.  
  19. return curl_exec($ch);
  20. }
  21.  
  22. function cURL($url)
  23. {
  24. $ch = curl_init();
  25. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3');
  26. curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
  27. curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
  28. curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  29. curl_setopt($ch, CURLOPT_URL,$url);
  30. curl_setopt($ch, CURLOPT_HEADER, false);
  31. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  32. curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
  33. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
  34.  
  35.  
  36. return curl_exec($ch);
  37. }
  38.  
  39. $url_login = 'http://www.manga-lib.pl/index.php/news/page/1';
  40. $login = 'username';
  41. $pass = 'password';
  42.  
  43. $url_po_zalogowaniu = 'http://www.manga-lib.pl/index.php/manga/download/fairy_tail,2';
  44.  
  45. cURL_POST($url_login,'login='.$login.'&password='.$pass);
  46. echo cURL($url_po_zalogowaniu);
  47.  
  48. ?>

I gdzieś w nim jest błąd i nie loguje mnie do serwisu tongue.gif jeżeli ktoś by mógł to proszę o poprawkę.
Z góry dzięki
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 03:57