next-sentence/oauth2-php-sdk

There is no license information available for the latest version (dev-master) of this package.

OAuth adapters

dev-master 2016-02-03 13:44 UTC

This package is auto-updated.

Last update: 2024-04-05 07:10:16 UTC


README

This PHP - SDK helps developer to connect to REST Api php application via OAuth2.

Example

<?php

use OAuth2\Factory;

require_once __DIR__ . './../vendor/autoload.php';

$config = array(
    'baseUri' => 'htttp://api.example.com',
    'client_id'     => 'client_id',
    'client_secret' => 'client_secret',
    'grant_type'    => 'password',
    'username'    => 'username',
    'password'    => 'password',
);

$factory  = new Factory();
$api = $factory->createApi($config);
try {
    $response = $api->call('v1/users.json', 'GET', $params = array());
    if ('200' == $response->getStatusCode()) {
        $users = json_decode($response->getContent());

        var_dump($users);
    }
} catch (Exception $e) {
    echo $e->getMessage();
}