Posté automatiquement une annonce sur leboncoin via curl

touriste57
Invité n'ayant pas de compte PHPfrance

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,
<?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;

?>
Modifié en dernier par zeus le 07 déc. 2011, 13:18, modifié 1 fois.
Raison : Remplacement des balises [code] en balises [php]

touriste57
Invité n'ayant pas de compte PHPfrance

28 juil. 2010, 11:14

Bonjour,
Je vois que vous n'avez pas plus d'idée que moi.
Tant pis. Je continue de chercher et si je trouve la solution je la posterais.

Si vous avez une idée merci de votre aide

Did

Invité
Invité n'ayant pas de compte PHPfrance

28 juil. 2010, 11:47

Bonjour,

pourquoi as tu mis check_type_diff à 0 ?
Dans le formulaire la valeur est 1 en hidden

eniot666
Invité n'ayant pas de compte PHPfrance

08 sept. 2011, 17:01

Bonjour,

Je cherche a faire la meme chose que toi... :D Es-ce que par hazard tu partagerai ton code final ?

Merci par avance.

Eniot

Eléphanteau du PHP | 29 Messages

02 déc. 2011, 00:00

J'ai développé une solution à base de VB pour ce faire.
Pour les intéressés => MP :)

asiaze
Invité n'ayant pas de compte PHPfrance

05 déc. 2011, 01:33

Bonjour et je suppose qu'il faut payer bien sûr :)

Gilliocq
Invité n'ayant pas de compte PHPfrance

21 janv. 2012, 16:53

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,
<?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;

?>