Skip to content

Instantly share code, notes, and snippets.

@etaubman
Created July 26, 2013 23:48
Show Gist options
  • Save etaubman/6092997 to your computer and use it in GitHub Desktop.
Save etaubman/6092997 to your computer and use it in GitHub Desktop.
Pull Station Data from CitiBikeNYC
<?php
/**
* Utility file to pull Citibike Station Data and write to a log file
* get_data.php
*/
function get_data () {
$href = "http://citibikenyc.com/stations/json";
$json = file_get_contents($href);
return $json;
}
function write_file ($contents) {
$filename = "/home/ec2-user/citibike/data/".time().".log";
if(! $handle = fopen($filename,"a+")) {
die();
}
else {
if (! fwrite($handle, $contents)) {
die();
}
fclose($handle);
}
}
write_file(get_data());
//End of File
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment