Optus Broadband Scraper Class b0.3 by Jesse Collis jesse.collis@gmail.com
This purpose of this project is to make some headway in getting back the now defunct XML and text files that people were using to access their broadband usage from 3rd party tools and applications.
Development for this project will be ongoing and is hosted @ http://code.google.com/p/optusscrape/ Please direct any feedback to me directly, or onto the Google code bug tracker.
Initial Notes
- This has not been tested with anything other than my own account so I don't know if it will work for you. If it doesn't please let me know.
- This code uses your personal details to log into your Optus account for you ∴ it has the same security risks associated with it as anything else that uses your personal details.
- I've put this under the MIT license http://www.opensource.org/licenses/mit-license.php
USE THIS AT YOUR OWN RISK
Requirements
- This project was developed with (and requires at least) PHP Version 5.2.x.
- PHP-Curl must be installed. OSX Leopard comes with this by default. Check http://au.php.net/manual/en/curl.requirements.php for more information.
- The class file MUST exist in a directory that it has write access too or have the $path variable to a relative path that the script has write access too.
Basic Usage
- Initialise the class with your username and password.
- 3rd parameter $path is the relative file path and defaults to the scripts directory. (Must have trailing slash!)
- 4th parameter $download lets you turn on/off the curl requests
- 5th parameter $userAgent lets you override the default 'Mozilla/Mac OSX' user agent.
EG: $myUsage = new OptusnetScraper('username','password');
- You can then access your various usage details directly from $myUsage.
EG: echo $myUsage->data_used;
- NB: For a list of available parameters, use the utility function params().
To view the contents of the returned array use var_dump().
EG: (array) $myUsage->params();
Generating XML
Using the $domdocument instance variable will return an instance of the DOMDocument class with all the elements initialised that are mentioned in the params() function.
EG: $myUsage->domdocument;
There's lots you can do from here, like saving the XML to a file or outputting it to the browser. All the more advanced options are listed neatly in the PHP Documentation.
I have included one useful method that will return an XML string or output XML directly to the browser. It's default is to return the string. If you want proper XML headers and automatic output then pass TRUE as the first parameter.
EG: $myUsage->outputXML(true); This will output the XML to the browser
The line above will output the following by default.
If you want to leverage this class to feed XML into another application then simply learn to use the DOMDocument Class. @ http://au.php.net/manual/en/class.domdocument.php