It's one area I'm not very good at, is working out the query strings and post data for logging into sites programmatically.
I do use TUC for a usage tracking app I have at home (like to corroborate it will gargoyles reported usage) - with the the spark change that's broken. I know he'll fix it, but I'd like to remove my reliance on it, and deal with it myself.
Also have asked many times for an API, and basically told no.
So what I've worked out is there should be a request to:
https://www.spark.co.nz/portal/site/digital-site/template.PAGE/action.process/menuitem.354c3e0302b1aa1994910bf3bc407ea0/?javax.portlet.action=true&javax.portlet.tpst=b85a693813b5760362a127b4bc407ea0&javax.portlet.begCacheTok=com.vignette.cachetoken&javax.portlet.endCacheTok=com.vignette.cachetoken
With the post data of:
loginSrc=ext
username=<email address>
password=<password>
and what seems to be a new key of:
sign-in=Sign In (which encoded is Sign+In)
But whenever I get the response back it always seems to be back to the sign in page. And I can't see an error reported in the html/
So here's the code:
System.Net.WebRequest req = System.Net.WebRequest.Create(mURL);
req.Method = "POST";
byte[] send = System.Text.Encoding.Default.GetBytes("loginSrc=ext&username=<encoded email address>&password=<password>&sign-in=Sign+In");
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = send.Length;
req.Proxy = System.Net.WebRequest.DefaultWebProxy;
System.IO.Stream sout = req.GetRequestStream();
sout.Write(send, 0, send.Length);
sout.Flush();
sout.Close();
System.Net.WebResponse res = req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(res.GetResponseStream());
lcHtml = sr.ReadToEnd();
Any help appreciated.
