Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][+ cURL] odpowiadanie w temacie
Chelo
post
Post #1





Grupa: Zarejestrowani
Postów: 178
Pomógł: 8
Dołączył: 19.03.2007

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


Witam wszystkich. Chciałem napisać skrypt, który odpowie mi automatycznie np. w tym temacie, tak więc w curl musi się pierw zalogować, a pozniej napisac odpowiedź. Jednak mam trochę problem ;/

probowalem napisać, jednak logowanie nawet mi się nie udaje

  1. $url ="http://www.test/login.php?username=sss&password=sss&autologin=on&login=Log+in";
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  4. curl_setopt($ch, CURLOPT_URL, $url);
  5. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  6. curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=sss&password=sss&autologin=on&login=Log+in");
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  8. curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  9. curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
  10. curl_exec ($ch);
  11. curl_close ($ch);


bądź:

  1. function curl_http_request ( $url , $options )
  2. {
  3. $handle = curl_init ( $url );
  4. foreach ( $options as $option => $value ) curl_setopt ( $handle , constant ( $option ), $value );
  5. $buffer = curl_exec ( $handle );
  6. curl_close ( $handle );
  7. return $buffer;
  8. }
  9.  
  10. curl_http_request ( 'http://www.test.org/login.php?' , array(
  11. 'CURLOPT_POST' => true ,
  12. 'CURLOPT_FOLLOWLOCATION' => true ,
  13. 'CURLOPT_POSTFIELDS' => 'username=ss&password=ss&autologin=on&login=Log+in' ,
  14. 'CURLOPT_USERAGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.6) Gecko/2009011912 Firefox/3.0.6' ,
  15. 'CURLOPT_COOKIEJAR' => 'cookie.txt' ,
  16. 'CURLOPT_COOKIEFILE' => 'cookie.txt'
  17. ));


proszę o pomoc
Powód edycji: [Ociu]: Poprawiłem bbCode
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 16.09.2025 - 12:49