sportlobster / digits
PHP library for Digits by Twitter
v0.3.0
2017-01-19 11:26 UTC
Requires
- php: ^5.6|^7.0
- guzzlehttp/guzzle: ^6.2
- psr/log: ^1.0
- symfony/serializer: ^3.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpspec/phpspec: ^3.2
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2025-04-26 23:42:08 UTC
README
PHP library for Digits by Twitter.
Usage
Simple example of server side verification:
use Sportlobster\Digits\Client;
use Sportlobster\Digits\Exception\AuthenticationException;
$client = Client('YOUR_DIGITS_CONSUMER_KEY');
// Verify a user via OAuth Echo
try {
$user = $client->verify($echoUrl, $echoAuth);
} catch (AuthenticationException $e) {
// User could not be authenticated
}
// Get details about the user
$user->getId();
$user->getPhoneNumber();
// Get details about the user's OAuth token
$accessToken = $user->getAccessToken();
$accessToken->getToken();
$accessToken->getSecret();
The underlying HTTP client (Guzzle) can be configured. This allows the ability to set request timeout options, proxies etc.
use Sportlobster\Digits\Client;
// See http://docs.guzzlephp.org/en/latest/request-options.html
$options = [
'connect_timeout' => 3.14,
'proxy' => 'tcp://localhost:8125',
];
$client = Client('YOUR_DIGITS_CONSUMER_KEY', $options);
In some scenarios you may have more than one set of Digits Keys that you wish to permit signing via (e.g. an iOS app and an Android app which share the same API service). In this case you can pass an array of keys to the Client instead:
use Sportlobster\Digits\Client;
$client = Client(['KEY1', 'KEY2', ...]);
Contributing
Classes are all specified using PHPSpec. To run:
vendor/bin/phpspec run
Integration tests are done via PHPUnit. To run:
vendor/bin/phpunit
Code must be to standards. To run:
php vendor/bin/php-cs-fixer fix