Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamwulf/automatic-php-api
A barebones PHP API for the Automatic API
https://github.com/adamwulf/automatic-php-api
Last synced: 3 days ago
JSON representation
A barebones PHP API for the Automatic API
- Host: GitHub
- URL: https://github.com/adamwulf/automatic-php-api
- Owner: adamwulf
- Created: 2013-10-16T21:37:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2019-07-04T06:24:37.000Z (over 5 years ago)
- Last Synced: 2024-05-01T12:29:57.716Z (7 months ago)
- Language: PHP
- Homepage: https://www.automatic.com/developer/
- Size: 16.6 KB
- Stars: 24
- Watchers: 8
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Automatic PHP API
This is a PHP client library for the Automatic API (http://www.automatic.com/). The Automatic Link plugs into your car's data port and connects to your phone to help you track and improve your driving habits. This API gives you access to the data stored in your Automatic account, including some of your car information and driving history. The Automatic API is in early alpha, and more functionality is expected to be released soon.
## Authentication
The Automatic API uses OAuth2 to authenticate against their website.
## Cloning this Repo
This repo uses a PHP OAuth2 library for authentication as a submodule. When cloning, be sure to:
```
$ git clone [email protected]:adamwulf/automatic-php-api.git
$ cd automatic-php-api
$ git submodule init
$ git submodule update
```## Usage
Below is a simple code snippet that shows how to authenticate with the API and send requests to fetch the user's trip information.
```
$automatic = new Automatic($your_client_id, $your_client_secret);// logging in with OAuth2 code
if (/* have a stored token somewhere in $_SESSION or the database */){
$automatic->setOAuthToken($the_stored_token_to_reuse);
}else if (!isset($_GET['code'])){
// we don't have a token stored, so fetch one
$scopes = array("scope:location", "scope:vehicle", "scope:trip:summary");
$auth_url = $automatic->authenticationURLForScopes($scopes);
header('Location: ' . $auth_url);
die('Redirect');
}
else
{
$response_token = $automatic->getTokenForCode($_GET["code"]);
// store and re-use this $response_token to save the user's login
// across multiple requests
$automatic->setOAuthToken($response_token);
}$trip_data = $automatic->getTrips();
```## Documentation
The Automatic API documentation is available at: https://www.automatic.com/developer/documentation/
More information is available at: https://www.automatic.com/developer/