Friday, October 22, 2010

Starbucks Wi-Fi

I ran into a small problem at a Starbucks store the other day.  I had my netbook with me and wanted to connect to their Wi-Fi network.  The service is free, but in order to access the Internet, you must first visit a Starbucks webpage that asks you to accept their terms and conditions.  Any attempt to visit any other website will redirect you to this page.

I like to have my browser reopen all the tabs from my last browsing session when it starts up.  My problem was that, because I have to accept the terms and conditions first, all my tabs would redirect to the Starbucks page.  Clicking the back button after accepting the terms and conditions doesn't return me to my original page.  I think that this is because it's a HTTP 3xx redirect response.  So I basically lose all my tabs.

Getting around this wasn't too tricky.  The terms and conditions page is just an HTML form with a bunch of hidden parameters and a checkbox for "I agree".  I wrote a Java program to parse all the parameters out of the page and submit the form.  So if I run this before opening my browser, my browser will reload all its tabs no problem.  No annoying redirects to the Starbucks page.

You can download it here.  I put all the classes in one file to make it simpler.  I also wrote some JUnit tests to test the part that parses the HTML page.  To run it, just compile the file and run java Starbucks -v.  The -v (verbose) is optional and will cause it to print status messages as it's working.  Run this program as soon as you connect to the Starbucks Wi-Fi network (and before you open your browser).

6 comments:

vzaliva said...

I am writing a small android program to automate Starbucks login. It is free and licensed under GPL.
Can I use parts of our code in it? Thanks!

Michael Angstadt said...

We never wrote any code together, but if you mean "my code", feel free to use it.

vzaliva said...

Thanks! I made a typo. I meant "your code".
The program is almost ready. You can see it here:

http://code.google.com/p/sbautologin/

Tom Collins said...

The source code is missing. Can you re-post it?

Michael Angstadt said...

I've moved it here:

https://github.com/mangstadt/Public-Wifi-Accepter

Tom Collins said...

Got it, thanks.