I'm in the process of making a personal program for myself (I've made a thread on it before) in which I make an Amazon recent items checker where I can just pull all my purchases and populate them in a listview on the form.
up to this point I've been using a webbrowser, but that method is taking way to long. So I figured I would have a go with webrequests and try it that way, I've been trying and trying but I can't replicate the POST request to login to http://Amazon.com.
Here's my code:
var request = (HttpWebRequest)WebRequest.Create("https://www.amazon.com/ap/signin?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fyourstore%2Fhome%3Fie%3DUTF8%26ref_%3Dgno_signin");
var postData = "All this data is so long, there's no point of posting it";
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
File.WriteAllText(@"C:\Users\Admin\Desktop\Source.html", responseString);
As you can see I'm outputting the source to check if it logs in, but it always just gives me the login page right back, does anyone have any ideas?