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 :: Версия для печати :: curl пост запрос после автозации
Форумы портала PHP.SU » » Работа с сетью » curl пост запрос после автозации

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

1. xhugo - 23 Мая, 2011 - 21:25:34 - перейти к сообщению
я авторизируюсь вконтакте,
PHP:
скопировать код в буфер обмена
  1.     $mail="";
  2.     $password="";
  3.     $cfile = 'cookies.txt';  
  4.     $ch = curl_init();  
  5.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
  6.     curl_setopt($ch, CURLOPT_URL, "http://vkontakte.ru/login.php?m=1&email=$mail&pass=$password");  
  7.     curl_setopt ($ch, CURLOPT_USERAGENT, "Opera/9.64 (Windows NT 5.1; U; ru) Presto/2.1.1");  
  8.     $headers = array(  
  9.     'Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',    'Accept-Language: ru-RU,ru;q=0.9,en;q=0.8',  
  10.     'Content-Type: application/x-www-form-urlencoded',  
  11.     'Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1',  
  12.     'Accept-Encoding: deflate',  
  13.     'Cookie2: $Version=1',  
  14.     'Connection: Keep-Alive, TE',  
  15.     'TE: deflate, gzip, chunked, identity, trailers');  
  16.     curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);  
  17.     curl_setopt($ch, CURLOPT_HEADER, 0);  
  18.     curl_setopt($ch, CURLOPT_COOKIEJAR, $cfile);  
  19.     curl_setopt($ch, CURLOPT_COOKIEFILE, $cfile);  
  20.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);  
  21.     curl_setopt($ch,CURLOPT_ENCODING , "gzip");  
  22.     echo $result = curl_exec($ch);

как же мне послать пост запрос, через авторизацию на сайт вконтакте и вернуть результат?
2. OrmaJever - 23 Мая, 2011 - 22:02:38 - перейти к сообщению
xhugo пишет:
я авторизируюсь вконтакте

Хи досихпор? )) 2 месяца назад тоже авторизировался в вк
А теперь по теме:
Нужно послать 2 запроса, 1 на авторизацию а второй уже с пост запросом и вывести 2 результат, если второй результат скажет что ты не авторизирован то посмотри в файл
PHP:
скопировать код в буфер обмена
  1.    $cfile = 'cookies.txt';
  2. ...
  3.     curl_setopt($ch, CURLOPT_COOKIEJAR, $cfile);  
  4.     curl_setopt($ch, CURLOPT_COOKIEFILE, $cfile);
  5.  

есть ли вобще этот файли сохраняются ли там куки
3. xhugo - 24 Мая, 2011 - 13:34:50 - перейти к сообщению
отправляю пост запрос, чтобы запостить запись на стене..
PHP:
скопировать код в буфер обмена
  1. function post($url,$file,$post)
  2. {
  3. $postData = $post;
  4. $curl = curl_init($url);
  5. curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
  6. curl_setopt($curl, CURLOPT_POST, 1);
  7. curl_setopt($curl, CURLOPT_HEADER, 0);
  8. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  9. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  10. curl_setopt($curl, CURLOPT_COOKIEJAR, $file);
  11. curl_setopt($curl, CURLOPT_COOKIEFILE, $file);
  12. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  13. curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
  14. $rsp = curl_exec($curl);
  15. curl_close($curl);
  16. unset($curl);
  17. return $rsp;
  18. }
  19. # берем хеш
  20. preg_match_all('|post_hash(.*)media_types|im',post('http://vkontakte.ru/','cookies.txt',''),$proxy);  
  21. $s= $proxy[1][0];
  22. $a=array('"',':',',');
  23. $s=str_replace($a,'',$s);
  24. $s=trim($s);
  25. $s='act=post&al=1&hash='.$s.'&message=ssss&to_id=00000000&type=all';
  26. echo post('http://vk.com/al_wall.php','cookies.txt',$s);

а получаю это:3485036273
в чем проблема?
4. OrmaJever - 24 Мая, 2011 - 13:39:41 - перейти к сообщению
xhugo пишет:
PHP:
скопировать код в буфер обмена
  1. preg_match_all('|post_hash(.*)media_types|im',post('http://vkontakte.ru/','cookies.txt',''),$proxy);

откуда на http://vkontakte[dot]ru/ post_hash(.*)media_types ?
5. xhugo - 24 Мая, 2011 - 16:23:59 - перейти к сообщению
в самом низу
PHP:
скопировать код в буфер обмена
  1. "max_post_len":280,"post_hash":"11e5efedeabc2af8e5","media_types":[["graffiti","Граффити"],["photo","Фотографию"]

этот хеш передавался отправки записи, когда смотрел сниффером

 

Powered by ExBB FM 1.0 RC1