c# - POST a variable to a website accepting JavaScript -


as title referring, there website requires key in order authenticate. key processed website , spits out. built program gets key, filters out html response , prints it.

all need know how post key javascript variable "key=" onto website "https://www.website.com/serve/credit" javascript on website:

 key = jquery('#my_key').val();     jquery.post('/serve/credit', "key=" + key); 

that javascript off of website;

console.writeline(resultstring); //resultstring key filter                  byte[] postbyte = encoding.ascii.getbytes(resultstring);                  httpwebrequest request2 = (httpwebrequest)httpwebrequest.create("https://www.website.com/serve/credit");                 request2.keepalive = true;                 request2.timeout = 15000;                 //request2.useragent = @"mozilla/5.0 (windows nt 6.2; win64; x64) applewebkit/537.36 (khtml, gecko) chrome/32.0.1667.0 safari/537.36";                 //request2.accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";                 //request2.headers.add(httprequestheader.acceptlanguage, "en-us,en;q=0.5");                 request2.method = "post";                 request2.contenttype = "application/x-www-form-urlencoded";                 request2.contentlength = postbyte.length;                 stream poststream = request2.getrequeststream();                 poststream.write(postbyte, 0, postbyte.length);                 poststream.close();                  httpwebresponse webresponse = (httpwebresponse)request2.getresponse();                 stream responsestream = webresponse.getresponsestream();                 streamreader responsestreamreader = new streamreader(responsestream);                 string result2 = responsestreamreader.readtoend();                 console.writeline(result2); 


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -