auto post article

fay_wang

New member
Joined
Dec 7, 2005
Messages
1
Programming Experience
3-5
I'm trying to log on and post an article automatically.It doesn't work. Could you guys look at the code and tell me what I missed? Thanks!

This is the forum I'm trying: http://www.mediasyndicate.com/user.php
The input parameters are:
page:http://www.mediasyndicate.com/user.php
data:&uname=stockmat&pass=xVw834Xv&rememberme=1&module=NS-User&op=login&url=/user.php

The code is follows:

private string Req_Res(string page,string data,string enctype) {
System.Text.ASCIIEncoding encoding = new ASCIIEncoding();

byte[] Data = encoding.GetBytes(data);
System.Net.HttpWebRequest postReq = (HttpWebRequest)WebRequest.Create(page);

postReq.KeepAlive = true;
postReq.Method ="POST";
postReq.AllowAutoRedirect =false;
if (enctype.Trim().Length !=0 )
{
postReq.ContentType =enctype;
}
postReq.ContentLength =Data.Length;

System.IO.Stream SendReq = postReq.GetRequestStream();
SendReq.Write(Data,0,Data.Length);
SendReq.Close();
System.Net.HttpWebResponse myHttpWebResponse = (HttpWebResponse)postReq.GetResponse();
Stream receiveStream = myHttpWebResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream);

String html =readStream.ReadToEnd();
return html;
}
user_online.gif
 
Back
Top