Posté automatiquement une annonce sur leboncoin via curl
Posté : 27 juil. 2010, 15:59
Bonjour,
Je suis en train de chercher un faire un script pour poster automatiquement une annonce sur le site du bon coin . fr
J'ai commencé un script mais ca ne marche pas. Je pense qu'il le manque pas grand chose. Pourriez vous m'aider?
D'avance merci,
Je suis en train de chercher un faire un script pour poster automatiquement une annonce sur le site du bon coin . fr
J'ai commencé un script mais ca ne marche pas. Je pense qu'il le manque pas grand chose. Pourriez vous m'aider?
D'avance merci,
<?php
$fp = fopen("cookies.txt",'wb');
fclose($fp);
$useragent = "Mozilla/5.0";
$url = "http://www2.leboncoin.fr/ai/preview/1";
$ch = curl_init($url);
//curl_setopt($ch , CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
$referer = $url;
$postfields = array();
$postfields["check_type_diff"] = "0";
$postfields["region"] = "18";
$postfields["dpt_code"] = "49";
$postfields["zipcode"] = "49230";
$postfields["category"] = "2";
$postfields["company_ad"] = "1";
$postfields["type"] = "s";
$postfields["name"] = "aaa";
$postfields["email"] = "[email protected]";
$postfields["phone"] = "0240121652";
$postfields["phone_hidden"] = "1";
$postfields["subject"] = "Vends Renault Laguna Bleu Break";
$postfields["body"] = "Je vends ma Renault Laguna Break couleur noir. Elle a 76000km. ";
$postfields["price"] = "12000";
//$postfields["image"] = "C:\!\funpics\60440.jpg";
//postfields["image"] = "@60440.jpg";
$postfields["image"] = "";
$postfields["siren"] = "732829320";
$postfields["fuel"] = "2";
$postfields["regdate"] = "2007";
$postfields["mileage"] = "76000";
$postfields["gearbox"] = "2";
$postfields["validate"] = "Valider";
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
$result = curl_exec($ch);
curl_close($ch);
$url = "http://www2.leboncoin.fr/ai/confirm/3";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
$referer = $url;
$postfields = array();
$postfields["passwd"] = "wqazsx";
$postfields["passwd_ver"] = "wqazsx";
$postfields["create"] = "Valider";
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>