Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Помогите авторизоваться на сайте курлом
Форумы портала PHP.SU » » Работа с сетью » Помогите авторизоваться на сайте курлом

Страниц (1): [1]
 

1. Gjiod - 17 Июня, 2012 - 16:07:10 - перейти к сообщению
Добрый день, помогите авторизоваться на http://shf[dot]wm-panel[dot]com через пхп и курл
вроде все правильно делаю, и куки и ЮА и хедеры (и без них тоже), но никак не авторизует Недовольство, огорчение
2. romario0403 - 17 Июня, 2012 - 17:35:39 - перейти к сообщению
PHP:
скопировать код в буфер обмена
  1. <?PHP
  2. function post_content ($url,$postdata) {
  3.   $uagent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
  4.  
  5.   $ch = curl_init( $url );
  6.   curl_setopt($ch, CURLOPT_URL, $url);
  7.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8.   curl_setopt($ch, CURLOPT_HEADER, 0);
  9.   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  10.   curl_setopt($ch, CURLOPT_ENCODING, "");
  11.   curl_setopt($ch, CURLOPT_USERAGENT, $uagent);  // useragent
  12.   curl_setopt($ch, CURLOPT_TIMEOUT, 120);
  13.   curl_setopt($ch, CURLOPT_POST, 1);
  14.   curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  15.   curl_setopt($ch, CURLOPT_COOKIEJAR, "coo.txt");
  16.   curl_setopt($ch, CURLOPT_COOKIEFILE,"coo.txt");
  17.  
  18.   $content = curl_exec( $ch );
  19.   $err     = curl_errno( $ch );
  20.   $errmsg  = curl_error( $ch );
  21.   $header  = curl_getinfo( $ch );
  22.   curl_close( $ch );
  23.  
  24.   $header['errno']   = $err;
  25.   $header['errmsg']  = $errmsg;
  26.   $header['content'] = $content;
  27.   return $header;
  28. }
  29.  
  30.   $url = 'http://shf.wm-panel.com/wm-panel/User/signin-do';
  31.   $username = '';
  32.   $userpass = '';
  33.   $postdata = 'log='.$username.'.ru&pas='.$userpass.'&inout=%D0%92%D1%85%D0%BE%D0%B4';
  34.  
  35.   $result = post_content( $url, $postdata );
  36.   $html = $result['content'];
  37.   echo $html;
  38. ?>


функция отсюда http://parsing-and-i[dot]blogspot[dot]co[dot][dot][dot]0/curl-post[dot]html
3. Gjiod - 17 Июня, 2012 - 21:53:02 - перейти к сообщению
Вроде получилось, но потом пишу
PHP:
скопировать код в буфер обмена
  1. $ch = curl_init();
  2. curl_setopt($ch, CURLOPT_URL, 'http://shf.wm-panel.com/wm-panel/Stats');
  3. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  4. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  5. curl_setopt($ch, CURLOPT_COOKIEFILE, 'coo.txt');
  6. $test = curl_exec($ch);
  7. file_put_contents ('C:\123.txt', $test);

Этот код чтобы в аккаунт перейти, и исходный текст такой, как будто я не авторизован Недовольство, огорчение
В чем дело (

 

Powered by ExBB FM 1.0 RC1