是否可以通过我自己的网站向 Craigslist 发帖?
我想做的是允许用户使用 PHP curl 通过我自己的网站向 Craiglist 发帖。这不是一个自动发帖系统,我只是希望用户能够同时在 Craigslist 和我的网站上发帖。到目前为止,我已经成功使用php登录,但我仍然不知道如何发布标题、描述、联系信息等。我对cURL不熟悉。
我正在使用通过 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);
?>
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);
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道这是否可能(可能是),但它违反 Craigslist TOS,所以要小心。
I don't know if this is possible (it probably is), but it is against Craigslist TOS, so be careful.