What I am trying to do is allow users to making postings to Craiglist through my own website using PHP curl. This is NOT an automated posting system, I just want users to be able to post onto Craigslist and my website at the same time. So far, I've 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'm working with a script I found through Google:
<?php
// INIT CURL
$ch = curl_init();
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'https://accounts.craigslist.org/');
// ENABLE HTTP POST
$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(); // execute the curl command
curl_close ($ch);
unset($ch);
//initialize second curl
$ch = curl_init();
//second curl
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;
// CLOSE CURL
curl_close ($ch);
?>
I don't know if this is possible (it probably is), but it is against Craigslist TOS, so be careful.
- POSTING AGENTS
A "Posting Agent" is a third-party agent, service, or intermediary that offers to post Content to the Service on behalf of others. To moderate demands on craigslist's resources, you may not use a Posting Agent to post Content to the Service without express permission or license from craigslist. Correspondingly, Posting Agents are not permitted to post Content on behalf of others, to cause Content to be so posted, or otherwise access the Service to facilitate posting Content on behalf of others, except with express permission or license from craigslist.