I'm using the following code to log into Craigslist, but haven't succeeded yet.
string formParams = string.Format("inputEmailHandle={0}&inputPassword={1}", "[email protected]", "removed");
//string postData = "[email protected]&inputPassword=removed";
string uri = "https://accounts.craigslist.org/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.KeepAlive = true;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "POST";
byte[] postBytes = Encoding.ASCII.GetBytes(formParams);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
cookyHeader = response.Headers["Set-cookie"];
string pageSource;
string getUrl = "https://post.craigslist.org/del";
WebRequest getRequest = WebRequest.Create(getUrl);
getRequest.Headers.Add("Cookie", cookyHeader);
WebResponse getResponse = getRequest.GetResponse();
using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
{
pageSource = sr.ReadToEnd();
}
Go to Craigslist.org, click the “cities” link and select where you want your ad to run. Click the “post to classifieds” link on the left-hand side of the page. You'll be prompted to log into your Craigslist account or create one if you don't have one. Once you've logged in, choose “service offered,” then “continue.”
Use WebTest to record your login process, then generate the code. This will help you to understand what is wrong with YOUR code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With