Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Oyster card journey scraper
PHP
branch: master

This branch is 3 commits behind ollieread:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
OysterJourney.php
README.md

README.md

Oyster Journey

This class is a simple scraper class that allows for users of the TFL Oyster website to scrape their journey information and access it as a nice array.

I have a live example here.

In total the class took me around an hour, so I apologise if it seems overly hacky but scraping is not as easy as one would like it to be.

Bug fixes, use cases, updates, suggestions and examples of this being used are welcomed, no, encouraged!

Quick Example

<?php
require_once 'OysterJourney.php';

try {
    // grab it
    $OysterJourney = new OysterJourney();
    $OysterJourney->setUsername('');
    $OysterJourney->setPassword('');
    $OysterJourney->setCookie('');

    $OysterJourney->loginAndGetCookie();
    // check its status
    if($OysterJourney->didItWork() === true) {
        // get the journey info
        $data = $OysterJourney->getJourney();
        // output
        echo '<pre>';
        print_r($data);
        echo '</pre>';
    }
} catch(Exception $e) {
    // you fucking idiot, you broke my code!
    echo $e->getMessage();
}
Something went wrong with that request. Please try again.