Not an API but some PHP Classes to get at your Fuelly Data
I know many people (including myself) wish Fuelly had an API so that we could fetch data and display it inline on our site. The only suggestions I have seen is to export to csv and import to your site or write a script that would login as your user and export/import on it's own.
However this is just messy. I have created a set of PHP classes that use the DOM to get at the data that Fuelly displays in-line on the site. Currently it requires your username and password and fetches your list of vehicles based on that. Once it has a list of vehicles it will loop over them and fetch the data associated with them, along with the last X fuelups, this number is configurable by changing a class constant currently. I know it's not the best way but this code is a work in progress and I will be extending upon it so that everyone who wishes to use it can benefit from it.
You can download and view the code at
http://www.josephcrawford.com/wp-con...-0.1-alpha.zip
It's pretty straight forward, basically you create a fuelly_user instance with your username and password. Then you get an instance of the fuelly_scraper class passing it the user and call the run method. It will return a populated user object like the following:
Code:
object(Fuelly_User)#1 (5) {
["_email:private"]=>
string(23) "info@josephcrawford.com"
["_password:private"]=>
string(9) "password"
["_displayName:private"]=>
string(11) "jcrawford27"
["_isLoggedIn:private"]=>
bool(true)
["_vehicles:private"]=>
array(2) {
["cbr600rr"]=>
object(Fuelly_Vehicle)#4 (13) {
["_name:private"]=>
string(8) "cbr600rr"
["_id:private"]=>
string(5) "83630"
["_displayName:private"]=>
NULL
["_avgMilesPerGallon:private"]=>
string(4) "41.6"
["_lastMilesPerGallon:private"]=>
string(4) "41.1"
["_bestMilesPerGallon:private"]=>
string(4) "44.8"
["_avgPricePerGallon:private"]=>
string(5) "$3.94"
["_avgPricePerFuelUp:private"]=>
string(5) "$9.93"
["_avgPricePerMile:private"]=>
string(6) "$0.094"
["_totalFuelUps:private"]=>
string(2) "24"
["_totalSpent:private"]=>
string(7) "$238.37"
["_totalMilesTracked:private"]=>
string(5) "2,313"
["_fuelUps:private"]=>
array(10) {
[0]=>
object(Fuelly_Fuelup)#11 (6) {
["_timestamp:private"]=>
string(10) "1318285570"
["_odometer:private"]=>
int(0)
["_miles:private"]=>
string(4) "93.0"
["_gallons:private"]=>
string(4) "2.26"
["_milesPerGallon:private"]=>
string(4) "41.1"
["_pricePerGallon:private"]=>
string(5) "4.019"
}
}
["highlander"]=>
object(Fuelly_Vehicle)#3 (13) {
["_name:private"]=>
string(10) "highlander"
["_id:private"]=>
string(5) "93897"
["_displayName:private"]=>
NULL
["_avgMilesPerGallon:private"]=>
string(4) "30.7"
["_lastMilesPerGallon:private"]=>
string(4) "29.5"
["_bestMilesPerGallon:private"]=>
string(4) "32.0"
["_avgPricePerGallon:private"]=>
string(5) "$3.59"
["_avgPricePerFuelUp:private"]=>
string(6) "$46.25"
["_avgPricePerMile:private"]=>
string(6) "$0.117"
["_totalFuelUps:private"]=>
string(1) "2"
["_totalSpent:private"]=>
string(6) "$92.50"
["_totalMilesTracked:private"]=>
string(3) "790"
["_fuelUps:private"]=>
array(2) {
[0]=>
object(Fuelly_Fuelup)#13 (6) {
["_timestamp:private"]=>
string(0) ""
["_odometer:private"]=>
int(0)
["_miles:private"]=>
string(5) "400.0"
["_gallons:private"]=>
string(5) "12.50"
["_milesPerGallon:private"]=>
string(4) "32.0"
["_pricePerGallon:private"]=>
string(5) "3.599"
}
[1]=>
object(Fuelly_Fuelup)#25 (6) {
["_timestamp:private"]=>
string(0) ""
["_odometer:private"]=>
int(0)
["_miles:private"]=>
string(5) "390.0"
["_gallons:private"]=>
string(5) "13.23"
["_milesPerGallon:private"]=>
string(4) "29.5"
["_pricePerGallon:private"]=>
string(5) "3.590"
}
}
}
}
}
Hopefully one-day Fuelly will get an API going so that we can do things like this. I am not personally looking for a way to push data to Fuelly, I basically want to display some data on my site. I was originally going to put on my site how many miles I have driven today based on the fuel-ups for the current date but it will take a bit more work to get all that information.
__________________