c# - Login to mediawiki by api on wp7 -


i trying create app wp7 login wikipedia , translating pages. stuck right @ beginning since can't login through mediawiki api. relevant part of code goes this:

        data.append("action=login&lgname" + httputility.urlencode(textbox1.text));         data.append("&lgpassword=" + httputility.urlencode(passwordbox1.password));          request.begingetrequeststream(new asynccallback(getrequeststreamcallback),request);         request.begingetresponse(new asynccallback(getresponsecallback), request);          public void getrequeststreamcallback(iasyncresult asynchronousresult)         {            httpwebrequest request = (httpwebrequest)asynchronousresult.asyncstate;            stream poststream = request.endgetrequeststream(asynchronousresult);            byte[] bytedata = utf8encoding.utf8.getbytes(data.tostring());            poststream.write(bytedata, 0, data.length);            poststream.close();         }         private static void getresponsecallback(iasyncresult asynchronousresult)         {            httpwebrequest request = (httpwebrequest)asynchronousresult.asyncstate;             httpwebresponse response = (httpwebresponse)request.endgetresponse(asynchronousresult);            stream streamresponse = response.getresponsestream();            streamreader streamread = new streamreader(streamresponse);            string responsestring = streamread.readtoend();             streamresponse.close();            streamread.close();             response.close();     } 

the problems are:

on getrequeststreamcallback can't pass data string main function. how do this?

on getresponsecallback function how return responsestring string can output later?

what you're trying 2 asynchronous operations, 1 after - it's worth remembering beginxxx methods return before they've finished - in case, ask request stream write to, , ask response, bad things ensue.

it's possibly worth looking @ other examples, such in opensource code - you'll see don't typically call begingetresponse until you've finished writing stream returned endgetrequeststream


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -