2017 © Pedro Peláez
 

library toopher-api

Toopher PHP Client Library

image

toopher/toopher-api

Toopher PHP Client Library

  • Wednesday, July 8, 2015
  • by dshafer
  • Repository
  • 9 Watchers
  • 4 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 4 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

ToopherAPI PHP Client

Introduction

ToopherAPI PHP Client simplifies the task of interfacing with the Toopher API from PHP code. This project includes all the dependency libraries and handles the required OAuth and JSON functionality so you can focus on just using the API., (*1)

Learn the Toopher API

Make sure you visit http://dev.toopher.com to get acquainted with the Toopher API fundamentals. The documentation there will tell you the details about the operations this API wrapper library provides., (*2)

OAuth Authentication

The first step to accessing the Toopher API is to sign up for an account at the development portal http://dev.toopher.com and create a "requester". When that process is complete, your requester is issued OAuth 1.0a credentials in the form of a consumer key and secret. Your key is used to identify your requester when Toopher interacts with your customers, and the secret is used to sign each request so that we know it is generated by you. This library properly formats each request with your credentials automatically., (*3)

The Toopher Two-Step

Interacting with the Toopher web service involves two steps: pairing, and authenticating., (*4)

Pair

Before you can enhance your website's actions with Toopher, your customers will need to pair their phone's Toopher app with your website. To do this, they generate a unique, nonsensical "pairing phrase" from within the app on their phone. You will need to prompt them for a pairing phrase as part of the Toopher enrollment process. Once you have a pairing phrase, just send it to the Toopher API along with your requester credentials and we'll return a pairing ID that you can use whenever you want to authenticate an action for that user., (*5)

Authenticate

You have complete control over what actions you want to authenticate using Toopher (for example: logging in, changing account information, making a purchase, etc.). Just send us the user's pairing ID, a name for the terminal they're using, and a description of the action they're trying to perform and we'll make sure they actually want it to happen., (*6)

Librarified

This library makes it super simple to do the Toopher two-step. Check it out:, (*7)

require_once("toopher_api.php");

// Create an API object using your credentials
$toopherApi = new ToopherAPI($key, $secret);

// Step 1 - Pair with their phone's Toopher app
$pairingStatus = $toopherApi->pair("pairing phrase", "username@yourservice.com");

// Step 2 - Authenticate a log in
$authStatus = $toopherApi->authenticate($pairingStatus['id'], "my computer");

// Once they've responded you can then check the status
while($authStatus['pending']){
    $authStatus = $toopherApi->getAuthenticationStatus($authStatus['id']);
    sleep(1);
}
if($authStatus['granted']){
    // Success!
} else {
    // user declined the authorization!
}

Dependencies

Toopher manages dependencies with composer. To ensure all dependencies are up-to-date, execute the following command:, (*8)

$ composer install

from the root directory the package (the same directory that this README is located in), (*9)

Handling Errors

If any request runs into an error a ToopherRequestException will be thrown with more details on what went wrong., (*10)

Example code

Check out demo/toopher_demo.php for an example program that walks you through the whole process! Simply execute the script as follows:, (*11)

$ php demo/toopher_demo.php

To avoid being prompted for your Toopher API key and secret, you can define them in the $TOOPHER_CONSUMER_KEY and $TOOPHER_CONSUMER_SECRET environment variables, (*12)

Tests

To run all unit tests:, (*13)

$ phpunit test/test_toopher_api.php

Note: phpunit may be found in vendor/bin/php so your test command would be, (*14)

$ vendor/bin/phpunit test/test_toopher_api.php

The Versions

08/07 2015

dev-master

9999999-dev http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • ext-json *
  • php >=5.3.0
  • pear-pear.php.net/http_request2 >=2.1.1
  • pear-pear.php.net/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

31/03 2015

dev-lang-library-refactor

dev-lang-library-refactor http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication two-factor toopher

24/12 2014

dev-develop

dev-develop http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • ext-json *
  • php >=5.3.0
  • pear-pear.php.net/http_request2 >=2.1.1
  • pear-pear.php.net/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

20/11 2014

dev-feature/add-pair-sms-to-develop

dev-feature/add-pair-sms-to-develop http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-json *
  • pear-pear.php.net/http_request2 >=2.1.1
  • pear-pear.php.net/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

19/11 2014

dev-feature/add-pair-sms

dev-feature/add-pair-sms http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-json *
  • pear-pear.php.net/http_request2 >=2.1.1
  • pear-pear.php.net/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

18/11 2014

dev-fix-travis-ci-testing

dev-fix-travis-ci-testing http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-json *
  • pear-pear.php.net/http_request2 >=2.1.1
  • pear-pear.php.net/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

31/10 2013

dev-php53_syntax_support

dev-php53_syntax_support http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • ext-json *
  • pear-pear/http_request2 >=2.1.1
  • pear-pear/http_oauth >=0.2.3
  • php >=5.3.0

 

The Development Requires

authentication two-factor toopher

31/10 2013

dev-hotfix/add-error-handling

dev-hotfix/add-error-handling http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-json *
  • pear-pear/http_request2 >=2.1.1
  • pear-pear/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

05/08 2013

dev-lib-update

dev-lib-update http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-json *
  • pear-pear/http_request2 >=2.1.1
  • pear-pear/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

05/07 2013

dev-enable-travis-ci

dev-enable-travis-ci http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-json *
  • pear-pear/http_request2 >=2.1.1
  • pear-pear/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

28/05 2013

dev-client_side_otp_take2

dev-client_side_otp_take2 http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-json *
  • pear-pear/http_request2 >=2.1.1
  • pear-pear/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher

08/12 2012

dev-client_side_otp_validation

dev-client_side_otp_validation http://www.toopher.com/developer

Toopher PHP Client Library

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-json *
  • pear-pear/http_request2 >=2.1.1
  • pear-pear/http_oauth >=0.2.3

 

The Development Requires

authentication two-factor toopher