Giter Site home page Giter Site logo

automatic-php-api's Introduction

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/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.