Skip to content

A PHP SDK that can be used to communicate with an OAuth2 secured API.

License

Notifications You must be signed in to change notification settings

GeBeater/platform-php-sdk

Repository files navigation

platform-php-sdk

This PHP - SDK helps developer to use an Oauth2 secured platform.

Build Status Coverage Status Dependency Status

Last year, Bigpoint began using GitHub for open source projects. In this connection, a mandatory PHP repository should not be missing. That is why we published our first PHP-repository, a PHP-SDK that can be used to access an OAuth2 secured API.

We have some applications with clear and definable responsibilities which interact to support company-related processes. This is not a monolithic application but rather loosely coupled services. A significant added value to decouple the service brought us the usage of RESTful HTTP. The resulting API is protected with the OAuth2 protocol.

*The published PHP-SDK can be used to access these kinds of APIs. It is straightforward and in the early stages of development. However the project builds upon state-of-the-art standards and techniques. So, for example, the PSR-2 coding style guide is used as PHP coding conventions. The installation and the dependencies can be managed with Composer. In order to write and execute the tests, PHPUnit is used.

We look forward to read your constructive "GitHub issues and pull requests".

This entry was posted by Bernd Hoffmann on April 11, 2013 on blog.bigpoint.net

Example

<?php
require 'vendor/autoload.php';

$config = array(
    'client_id'     => 'CLIENTID',
    'client_secret' => 'CLIENTSECRET',
    'grant_type'    => 'authorization_code',
    //'grant_type'    => 'client_credentials',
    'redirect_uri'  => 'http://localhost', // optional, otherwise the current URI will used
);

$factory  = new Bigpoint\Factory();
$api      = $factory->createApi($config);
try {
    $user_id = $api->getUser();
    if (null !== $user_id) {
        $response = $api->call('/me');
        echo $response->getContent();
    }
} catch (Exception $e) {
    echo $e->getMessage();
}

The URI at which a request for an authorization will be serviced.

<?php
// ...
$api->getAuthorizationRequestUri();

Tests

The tests can be executed by using the phpunit command line tool from the base directory.

phpunit

The coverage report will generated to base directory/coverage.

The Xdebug extension is required otherwise no code coverage will be generated.

License

Apache License Version 2.0

About

A PHP SDK that can be used to communicate with an OAuth2 secured API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages