I am trying to check my gift card balance, (I have many) on the following website and I want to automate via a C# program.
It is form1 in the source code im interested in. This is my code:
class Program
{
public static string HttpPost(string url, params object[] postData)
{
StringBuilder post = new StringBuilder();
for (int i = 0; i < postData.Length; i += 2)
post.Append(string.Format("{0}{1}={2}", i == 0 ? "" : "&", postData[i], postData[i + 1]));
return HttpPost(url, post.ToString());
}
public static string HttpPost(string url, string postData)
{
postData = postData.Replace("\r\n", "");
try
{
WebRequest req = WebRequest.Create(url);
byte[] send = Encoding.Default.GetBytes(postData);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = send.Length;
Stream sout = req.GetRequestStream();
sout.Write(send, 0, send.Length);
sout.Flush();
sout.Close();
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
string returnvalue = sr.ReadToEnd();
return returnvalue;
}
catch (Exception ex)
{
Debug.WriteLine("POST Error on {0}\n {1}", url, ex.Message);
return "";
}
}
static void Main(string[] args)
{
HttpPost("http://ift.tt/2j3cupz",
"CardNumber", "CREDIT NUMBER",
"ExpirationMonth", "MONTH",
"ExpirationYear", "YEAR",
"SecurityCode", "CODE");
}
}
I just want to see if the website would give me a response. The following error is what I get:
POST Error on http://ift.tt/2j3cupz
The remote server returned an error: (404) Not Found.
How do I figure out what the real URL should be?
Aucun commentaire:
Enregistrer un commentaire