My most successful app to date has been Cheap Seats. A flight deals notification app released only in New Zealand and Australia.
Air New Zealand was slow to join the mobile revolution, so I decided to simplify my life and create an iOS app due to the lack of Adobe flash on iOS devices at the time. The app was the number 1 travel app in the New Zealand iTunes store, and had 75,000 active users.

Step 1: Grabbing the goods

The target URL (excluded for obvious reasons) contains JSON data from Air New Zealand.

1
2
3
$input=file_get_contents( ## target URL ##, 1000000 );
$input=str_replace( '@','',$input );
$anz = $json_decode( $input );

$anz returns PHP object such as:

1
2
3
4
5
6
7
8
9
object(stdClass)#1 (7) {
["bookUrl"]=> string(63) "https://flightbookings.grabaseat.co.nz/vbook/actions/ext-search"
["djBookUrl"]=> string(44) "http://www.virginaustralia.com/flightsearch/"
["onewayInternationalText"]=>
string(0) ""
["productBookUrl"]=> string(63) "https://flightbookings.grabaseat.co.nz/vbook/actions/ext-search"
["specialsStatus"]=> string(4) "open"
["storeFront"]=> string(2) "NZ"
["special"]=> array(14) {

Step 2: The interesting parts

The two parts of this data packet that we’re interested in are the “bookURL” string and “special” array.

1
2
3
4
5
// Air NZ booking URL
$booking_url = $anz->{ 'bookUrl' };
// Specials array
$specials = $anz->{ 'special' };

Step 3: Simplifying the dataset

It’s then just matter of extracting some of the items of interest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$new_specials = array();
$deals = array();
// Date keys
$date_keys = array( "bookFromDate","bookToDate","displayFromDate","displayToDate" );
foreach ( $specials as $deal ) {
foreach ( $deal as $key => $value ) {
if( in_array( $key, $date_keys ) ) {
$deals[ $key ] = date( 'j M y', strtotime( $value ) );
}
elseif( $key =="price" ) {
$deals[ $key ] = '"'.intval( $value ).'"';
}
else {
$deals[ $key ] = $value;
}
}
$deals["linkage"] = "?originPoint0=" . $deals[ "originIATACode" ];
$deals["linkage"] .= "&destinationPoint0=" . $deals[ "destinationIATACode" ];
$deals["linkage"] .= "&tripStartMonth=" . substr( $deals[ "bookFromDate" ], -6, 3 );
$deals["linkage"] .= "&tripStartDate=" . substr( $deals[ "bookFromDate" ], 0, -7 );
$deals["linkage"] .= "&tripEndMonth=" . substr( $deals[ "bookToDate" ], -6, 3 );
$deals["linkage"] .= "&tripEndDate=" . substr( $deals[ "bookToDate" ], 0, -7 );
$deals["linkage"] .= "&searchType=flexible";
$deals["linkage"] .= "&utm_source=gas";
$deals["linkage"] .= "&utm_medium=specials";
$deals["linkage"] .= "&utm_campaign=specials";
$new_specials[] = $deals;
}

Step 4: Usage

For Cheap Seats the specials array was repacked into JSON before being sent to the iPhone.

1
2
3
4
5
6
7
8
9
// Repack
$output = $json_encode($new_specials);
// Strip back slashes
$str = '{ "bookingURL":"'.$booking_url.'","specials":'.$output.' }';
$str = str_replace( '"', '', $str );
header( "Content-Type: application/json" );
print( $str );

I created a new revised version which included social aspects but by then Air New Zealand had joined the rest of the world.

Want to work with me?

Let's Talk!

Recently I've worked with ...