2017 © Pedro Peláez
 

library tsoauth

Tronsalt OAuth library

image

ova777/tsoauth

Tronsalt OAuth library

  • Wednesday, August 31, 2016
  • by ova777
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

tsoauth

Tronsalt OAuth library, (*1)

Usage:

Create TSOauth object

use ova777\TSOAuth;

$tsoauth = TSOAuth\Core::create(array(
    'auto_refresh_token' => true,
    'id' => 'OAUTH_CLIENT_ID',
    'secret' => 'OAUTH_CLIENT_SECRET',
    'host' => 'https://tronsalt.ru',
    'access_token' => '', //If exists
    'refresh_token' => '', //If exists
    'scope' => array('user.data'), //Required permissions
));

Reirect to User authentication

$tsoauth->goAuthorizationCode();

If User click "Cancel" (denied access)

There is redirect to your REDIRECT_URI with GET parameters "error" and "error_description", (*2)

if(isset($_GET['error'])) { ?>
    <b><?= $_GET['error'] ?></b><br/>
    <?= $_GET['error_description'] ?>
<?php }

If User is granted access

There is redirect to your REDIRECT_URI with GET parameter "code"
You need get "access_token" and "refresh_token" by the "code", (*3)

try {
    $tsoauth->getAccessTokenByCode($_GET['code']);
    //Save $tsoauth->access_token and $tsoauth->refresh_token for this User
} catch (TSOAuth\Except $error) {
    echo $error->asString();
}

If you have "access_token" and "refresh_token" - you can make transactions, (*4)

try {
    $transaction = $tsoauth->makeTransaction('500'); //Sum
    if(isset($transaction['actions'])) {
        $commit = $tsoauth->endTransaction($transaction['actions']['commit']);
        //print_r($commit);
    }
} catch (TSOAuth\Except $error) {
    echo $error->asString();
}

The Versions

31/08 2016

dev-master

9999999-dev http://github.com/ova777/tsoauth

Tronsalt OAuth library

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-curl *
  • ext-json *

 

oauth tronsalt

31/08 2016

v1.0.3

1.0.3.0 http://github.com/ova777/tsoauth

Tronsalt OAuth library

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-curl *
  • ext-json *

 

oauth tronsalt

10/08 2016

v1.0.2

1.0.2.0 http://github.com/ova777/tsoauth

Tronsalt OAuth library

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-curl *
  • ext-json *

 

oauth tronsalt

08/08 2016

v1.0.1

1.0.1.0 http://github.com/ova777/tsoauth

Tronsalt OAuth library

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-curl *
  • ext-json *

 

oauth tronsalt

08/08 2016

1.0.0

1.0.0.0 http://github.com/ova777/tsoauth

Tronsalt OAuth library

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-curl *
  • ext-json *

 

oauth tronsalt