What I'm trying to do is let users post to Craiglist through my own site using PHP curl. This is NOT an automatic posting system, I just want users to be able to post to Craigslist and to my site at the same time. So far I have managed to log in using php, but I'm still not sure how to post the title, description, contact information, etc. I am not familiar with cURL.
I am working with a script found through Google:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://accounts.craigslist.org/');
$email = "email";
$pass = "pass";
$url = "inputEmailHandle=".urlencode($email)."&inputPassword=".urlencode($pass);
curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $url);
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
ob_start();
curl_exec ($ch);
ob_end_clean();
curl_close ($ch);
unset($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_URL, 'http://sandiego.craigslist.org/sub/');
$content = curl_exec ($ch);
echo $content;
curl_close ($ch);
?>
source
share