Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Logowanie CURL, jw
miras
post
Post #1





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Witam, temat kiedyś już poruszałem, dawno temu, ale muszę do tego wrócić.. muszę zrobić logowanie curl'em do dziennika elektronicznego, link:
http://uonet.vulcan.net.pl/001606 mój kod zwraca mi tylko 1 ... co tu jest nie tak?


  1. <?php
  2. $content = file_get_contents("https://uonet.vulcan.net.pl/001606/LoginPage.aspx?ReturnUrl=%2f001606%2fstart.aspx");
  3. $id=explode('<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="',$content);
  4. $ide = explode('" />',$id[1]);
  5.  
  6. $content1 = file_get_contents("https://uonet.vulcan.net.pl/001606/LoginPage.aspx?ReturnUrl=%2f001606%2fstart.aspx");
  7. $id1=explode('<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="',$content1);
  8. $ide1 = explode('" />',$id1[1]);
  9.  
  10.  
  11.  
  12. function createPostString($aPostFields) {
  13. foreach ($aPostFields as $key => $value) {
  14. $aPostFields[$key] = urlencode($key) . '=' . urlencode($value);
  15. }
  16. return implode('&', $aPostFields);
  17. }
  18.  
  19. $input = array(
  20. 'ctl00$TheContentPlaceHolder$txtLogin' => 'x',
  21. 'ctl00$TheContentPlaceHolder$btLogin' => 'Logowanie',
  22. 'ctl00$TheContentPlaceHolder$txtPassword' => 'x',
  23. '__EVENTTARGET' => '',
  24. '__EVENTARGUMENT' => '',
  25. '__VIEWSTATE' => $ide[1],
  26. '__EVENTVALIDATION' => $ide1[1]
  27. );
  28.  
  29. $ch = curl_init();
  30. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
  31. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  32. curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
  33. curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  34. curl_setopt($ch, CURLOPT_URL, "https://uonet.vulcan.net.pl/001606/LoginPage.aspx?ReturnUrl=%2f001606%2fstart.aspx");
  35. curl_setopt($ch, CURLOPT_POSTFIELDS, createPostString($input));
  36. $data=curl_exec($ch);
  37. curl_close($ch);
  38. echo $data;
  39. ?>
  40.  
  41.  


--------------------
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: 20.08.2025 - 16:40