Показать сообщение отдельно

  #1  
Старый 27.08.2014, 01:54
de_angelo
Новичок
Регистрация: 13.09.2010
Сообщений: 2
Провел на форуме:
468

Репутация: 0
По умолчанию

Доброго времени суток.

хотел добавить в php, но мне кажется там наврятли есть знатоки работы с avito

Постинг на сайте через CURL достаточно простая затея, и дабы не платить 200$ за тот функционал что мне не нужен.

Написал сам. делов 3 минуты.

Тогда на m.avito был HTTP

Когда перешли они на HTTPS - не могу понять, не добавляет массив с номером картинки и все.

Сейчас если пытаешься вставить данные, не добавляет объявление.

(в данных POST 'images[0]'=> $img1)

раньше работало все.

если убрать строку images[0] все добавляет без проблем.

Может кто что подскажет? что поменялось?

кому нужен скрипт (код с html_dom.php и antigate распознавание captcha не вставлял, кто будет юзать добавьте сами=)

Код:
// LOGIN --------------------------------------------------
$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"https://m.avito.ru/profile/login"); 
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 6.2; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0");
	curl_setopt($ch, CURLOPT_COOKIEFILE, $cook);
	curl_setopt($ch, CURLOPT_COOKIEJAR, $cook);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	//curl_setopt($ch, CURLOPT_PROXY, "109.197.92.247:1080");
    //curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
     
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

	curl_setopt($ch, CURLOPT_REFERER, "https://m.avito.ru/profile/login");  
	curl_setopt($ch, CURLOPT_POSTFIELDS, "login=".$login."&password=".$passw."&next=%2Fprofile"); 
   curl_setopt($ch, CURLOPT_TIMEOUT,1000);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	//curl_setopt($ch, CURLOPT_PORT, 80);
	
$html31 = curl_exec($ch);
	

	
// 1 ОБЬЯВЛЕНИЕ ---------------------------------------------------------- Удаляем старое обьявление
$html3 = str_get_html($html31);
foreach($html3->find('article') as $m222) {	
foreach($m222->find('a') as $ma) { $ssulka =  $ma->href; }
} 
preg_match('#/item/(.*)#',$ssulka,$matches); 
if($matches[1] != "") {
curl_setopt($ch, CURLOPT_URL,"https://m.avito.ru/profile/item/".$matches[1]."/remove");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, "https://m.avito.ru/profile/item/".$matches[1]."/remove?xreferer=/profile");  
curl_setopt($ch, CURLOPT_POSTFIELDS, "xreferer=%2Fprofile&yes=%D0%A3%D0%B4%D0%B0%D0%BB%D0%B8%D1%82%D1%8C"); 
curl_setopt($ch, CURLOPT_TIMEOUT,1000); 
//curl_setopt($ch, CURLOPT_PORT, 80);
$html31 = curl_exec($ch);  
}

// Загрузка картинки ---------------------------------------------------------- 

function imgupload($filen) {
$patch1="/xampp/4ast/net/up_img/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://m.avito.ru/add/image");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
    curl_setopt($ch, CURLOPT_POST, true);
    $post1 = array("image"=>"@".$patch1.$filen);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post1); 
$response = curl_exec($ch);
$t3 = json_decode($response, TRUE);
return $t3['id'];
}
$img1= imgupload("ats1.jpg");
// Загрузка картинки ---------------------------------------------------------- 

// сливаем и распознаем captcha ---------------------------------------------------------- 
$ch1 = curl_init('https://m.avito.ru/captcha?1433333');
$fp1 = fopen('/up_img/capt.jpg', 'wb');
curl_setopt($ch1, CURLOPT_COOKIEFILE, $cook);
curl_setopt($ch1, CURLOPT_COOKIEJAR, $cook);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch1, CURLOPT_FILE, $fp1);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_exec($ch1);
curl_close($ch1);
fclose($fp1);

$key1 = recognize("/up_img/capt.jpg","1234567890",false, "antigate.com");

// сливаем и распознаем captcha ---------------------------------------------------------- 

//  массив POST

 $postdata=array(
 'seller_name'=>'Василий',
 'email'=>'y234445887@yandex.ru',
 'phone'=>'89045344333',
 'metro_id'=>'',
 'region_id'=>'653240',
 'captcha'=> $key1,
 'district_id'=>'',
 'location_id'=>'',
'images[0]'=> $img1,
 'category_id'=>'114',
 'params[716]'=>'10195',

 "image[0]"=>"@".$patch1."ats1.jpg",
 'title'=>'Валенки',
 'description'=>'Продаю валенки 42 размер',
 'price'=>'3000'
 ); 

echo "".$img1." - ";
	
//  закидываем данные	
curl_setopt($ch, CURLOPT_URL,"https://m.avito.ru/add");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, "https://m.avito.ru/add");  
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); 
$response7712 = curl_exec($ch);  

echo $key1;

//  выбираем беспл. обьявление
curl_setopt($ch, CURLOPT_URL,"https://m.avito.ru/add/service");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "service="); 
$html31 = curl_exec($ch);  

echo $html31;
 
Ответить с цитированием