Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




3731 posts

Uber Geek
+1 received by user: 438

Trusted

Topic # 150931 8-Aug-2014 08:44
Send private message

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.






Previously known as psycik

NextPVR/OpenHAB: 
Gigabyte AMD A8 Brix --> Samsung LA46A650D via HDMI, NextPVR,OpenHAB with Aeotech ZWave Controller
Media:Chromecast v2, ATV4, Roku3, Raspberry PI temperature Sensors and Bluetooth LE Sensors,HDHomeRun Dual
Windows 2012 
Host (Plex Server/Crashplan): 2x2TB, 2x3TB, 1x4TB using DriveBender, Samsung 850 evo 512 GB SSD, Hyper-V Server with 1xW10, 1xW2k8, 2xUbuntu 16.04 LTS, Crashplan, NextPVR channel for Plex,NextPVR Metadata Agent and Scanner for Plex


Create new topic
3087 posts

Uber Geek
+1 received by user: 851

Trusted

  Reply # 1104825 8-Aug-2014 12:27
Send private message

You might need to include cookies from the original page.  Give this a try, in a console app with HtmlAgilityPack and Json.net nuget packages installed:

https://gist.github.com/anonymous/d62d564370ba7523787a

It works for me to do something like what I assume you're trying to, giving an output like:

Used 15.4580920003355 of 30 GB for period 21/07/2014 - 20/08/2014

It's pretty hacky code but hopefully it gives the idea.

6303 posts

Uber Geek
+1 received by user: 378

Moderator
Trusted
Lifetime subscriber

  Reply # 1104835 8-Aug-2014 12:49
Send private message

Abit snowed under the moment, but pseudo code would be:

1. Hit this page (https://www.spark.co.nz/portal/site/digital-site/template.PAGE/signin/) and get the action part of the form
2. Post back the five different form values - username, password, redirectUrl, emailValidationToken, showSignInAsDifferentUser AND all the cookies as well (there's 16 of them in total)

Try and replicate the real page interactions exactly and it should work fine.

 
 
 
 




3731 posts

Uber Geek
+1 received by user: 438

Trusted

  Reply # 1104890 8-Aug-2014 14:19
Send private message

sidefx: You might need to include cookies from the original page.  Give this a try, in a console app with HtmlAgilityPack and Json.net nuget packages installed:

https://gist.github.com/anonymous/d62d564370ba7523787a

It works for me to do something like what I assume you're trying to, giving an output like:

Used 15.4580920003355 of 30 GB for period 21/07/2014 - 20/08/2014

It's pretty hacky code but hopefully it gives the idea.


Awesome.  I need to clean up what I've got, but I've managed to get a number out.  

I think the main bit might have been holding the cookies as you and Nate pointed out.

The page that I'm getting to is different than I've seen before (seems to almost be a data dump which is nice).

But I'll clean it up.  Thanks so much.





Previously known as psycik

NextPVR/OpenHAB: 
Gigabyte AMD A8 Brix --> Samsung LA46A650D via HDMI, NextPVR,OpenHAB with Aeotech ZWave Controller
Media:Chromecast v2, ATV4, Roku3, Raspberry PI temperature Sensors and Bluetooth LE Sensors,HDHomeRun Dual
Windows 2012 
Host (Plex Server/Crashplan): 2x2TB, 2x3TB, 1x4TB using DriveBender, Samsung 850 evo 512 GB SSD, Hyper-V Server with 1xW10, 1xW2k8, 2xUbuntu 16.04 LTS, Crashplan, NextPVR channel for Plex,NextPVR Metadata Agent and Scanner for Plex


11 posts

Geek
Inactive user


  Reply # 1105969 10-Aug-2014 17:33
Send private message

I'm having the same problems here. No help for their service desk. undecided



3731 posts

Uber Geek
+1 received by user: 438

Trusted

  Reply # 1106001 10-Aug-2014 19:11
Send private message

manly100: I'm having the same problems here. No help for their service desk. undecided


The same problems how? With an app that scrapes their site? No, they don't help you with that.




Previously known as psycik

NextPVR/OpenHAB: 
Gigabyte AMD A8 Brix --> Samsung LA46A650D via HDMI, NextPVR,OpenHAB with Aeotech ZWave Controller
Media:Chromecast v2, ATV4, Roku3, Raspberry PI temperature Sensors and Bluetooth LE Sensors,HDHomeRun Dual
Windows 2012 
Host (Plex Server/Crashplan): 2x2TB, 2x3TB, 1x4TB using DriveBender, Samsung 850 evo 512 GB SSD, Hyper-V Server with 1xW10, 1xW2k8, 2xUbuntu 16.04 LTS, Crashplan, NextPVR channel for Plex,NextPVR Metadata Agent and Scanner for Plex


Create new topic



Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

CPTPP text and National Interest Analysis released for public scrutiny
Posted 21-Feb-2018 19:43


Foodstuffs to trial digitised shopping trolleys
Posted 21-Feb-2018 18:27


2018: The year of zero-login, smart cars & the biometrics of things
Posted 21-Feb-2018 18:25


Intel reimagines data centre storage with new 3D NAND SSDs
Posted 16-Feb-2018 15:21


Ground-breaking business programme begins in Hamilton
Posted 16-Feb-2018 10:18


Government to continue search for first Chief Technology Officer
Posted 12-Feb-2018 20:30


Time to take Appleā€™s iPad Pro seriously
Posted 12-Feb-2018 16:54


New Fujifilm X-A5 brings selfie features to mirrorless camera
Posted 9-Feb-2018 09:12


D-Link ANZ expands connected smart home with new HD Wi-Fi cameras
Posted 9-Feb-2018 09:01


Dragon Professional for Mac V6: Near perfect dictation
Posted 9-Feb-2018 08:26


OPPO announces R11s with claims to be the picture perfect smartphone
Posted 2-Feb-2018 13:28


Vocus Communications wins a place on the TaaS panel
Posted 26-Jan-2018 15:16


SwipedOn raises $1 million capital
Posted 26-Jan-2018 15:15


Slingshot offers unlimited gigabit fibre for under a ton
Posted 25-Jan-2018 13:51


Spark doubles down on wireless broadband
Posted 24-Jan-2018 15:44



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.