next-sentence/oauth2-php-sdk

此软件包的最新版本(dev-master)没有可用的许可证信息。

OAuth适配器

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

This package is auto-updated.

Last update: 2024-09-05 08:03:53 UTC


README

此PHP - SDK帮助开发者通过OAuth2连接到REST Api php应用。

示例

<?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();
}