You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ToopherPHP is a Toopher API library that 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.
6
4
7
-
#### Learn the Toopher API
8
-
Make sure you visit [http://dev.toopher.com](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.
5
+
###PHP Version
6
+
\>=5.3.0
9
7
10
-
#### OAuth Authentication
8
+
### Documentation
9
+
Make sure you visit [https://dev.toopher.com](https://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.
11
10
12
-
The first step to accessing the Toopher API is to sign up for an account at the development portal [http://dev.toopher.com](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.
11
+
## ToopherApi Workflow
13
12
14
-
#### The Toopher Two-Step
15
-
Interacting with the Toopher web service involves two steps: pairing, and authenticating.
16
-
17
-
##### Pair
18
-
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.
19
-
20
-
##### Authenticate
21
-
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.
22
-
23
-
#### Librarified
24
-
This library makes it super simple to do the Toopher two-step. Check it out:
13
+
### Step 1: Pair
14
+
Before you can enhance your website's actions with Toopher, your customers will need to pair their mobile device's Toopher app with your website. To do this, they generate a unique pairing phrase from within the app on their mobile device. 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 web service 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.
25
15
26
16
```php
27
17
require_once("toopher_api.php");
28
18
29
19
// Create an API object using your credentials
30
20
$toopherApi = new ToopherApi("<yourconsumerkey>", "<yourconsumersecret>");
31
21
32
-
// Step 1 - Pair with their phone's Toopher app
33
-
// With pairing phrase
22
+
// Step 1 - Pair with their mobile device's Toopher app
You have complete control over what actions you want to authenticate using Toopher (logging in, changing account information, making a purchase, etc.). Just send us the username or pairing ID and we'll make sure they actually want it to happen. You can also choose to provide the following optional parameters: terminal name, requester specified ID and action name (*default: "Log in"*).
40
28
29
+
```php
41
30
// Step 2 - Authenticate a log in
42
-
// With a pairing id and terminal name
43
-
$authRequest = $toopherApi->authenticate($pairing->id, "my computer");
44
-
// With a username, terminal name and requester specified terminal id
45
-
$authRequest = $toopherApi->authenticate("username", "my computer", "requester specified id");
46
-
31
+
$authRequest = $toopherApi->authenticate("username", "my computer");
47
32
48
33
// Once they've responded you can then check the status
If any request runs into an error a `ToopherRequestException` will be thrown with more details on what went wrong.
64
75
65
-
#### Example code
66
-
Check out demo/toopher_demo.php for an example program that walks you through the whole process! Simply execute the script as follows:
76
+
###Demo
77
+
Check out `demo/toopher_demo.php` for an example program that walks you through the whole process! Simply run the command below:
67
78
```shell
68
79
$ php demo/toopher_demo.php
69
80
```
70
-
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
71
81
72
-
#### Tests
73
-
To run all unit tests:
82
+
## Contributing
83
+
### Dependencies
84
+
Toopher manages dependencies with [composer](http://getcomposer.org). To ensure all dependencies are up-to-date run the command below from the root directory:
85
+
```shell
86
+
$ composer install
87
+
```
88
+
89
+
### Tests
90
+
To run the tests enter:
74
91
```shell
75
92
$ phpunit test
76
93
```
77
-
Note: `phpunit` may be found in `vendor/bin/php` so your test command
78
-
would be
94
+
*Note: `phpunit` may be found in `vendor/bin/php` so your test command
95
+
would be:*
79
96
```shell
80
97
$ vendor/bin/phpunit test
81
98
```
82
99
83
-
####License
84
-
ToopherPHP is licensed under the MIT License. See LICENSE.txt for the full license text.
100
+
## License
101
+
ToopherPHP is licensed under the MIT License. See LICENSE.txt for the full text.
0 commit comments