Skip to content

einarpehrson/tuenti-php-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tuenti PHP SDK for Applications

version 1.0

Tuenti provides a set of application programming interfaces for trusted partners. Since early 2013, Tuenti offers a new platform for applications, both for applications embedded on Tuenti, integrated into the core user experience, and external websites wanting to provide a richer experience for Tuenti users. The application platform consists of a set of dialogs and a web service following the REST architectural style, protected by the industry-standard OAuth 2.0 protocol used for user authorization of applications. The PHP SDK for Applications provides a set of server-side functionality to facilitate use of platform API's from any context.

Features

The PHP SDK provides the following functionality.

Requirements

The PHP SDK requires the following PHP extensions.

Usage

In order to use the PHP SDK for Applications, the source code for the SDK must be downloaded from Github and included in your application. For convenience, all classes contained in the SDK are located in the file Tuenti.php. The main entrypoint to the SDK is the Tuenti class.

The following code snippet instantiates the SDK and configures it for use with your application.

require_once('Tuenti.php');

$tuenti = new Tuenti(array(
  'restApiBaseUrl' => '...',
  'clientId' => 'YOUR_CLIENT_ID',
  'clientSecret' => 'YOUR_CLIENT_SECRET'
));

In order to complete the OAuth 2.0 Authorization Code Grant flow by exchanging the obtained authorization code for an access token, typical applications will do the following.

$tuenti->setAccessTokenFromAuthorizationResponse();

Once an access token has been obtained, invoking the REST API is done in the following way.

if ($tuenti->hasAccessToken()) {
  $currentUser = $tuenti->api('/users/current')->get();
}

See the examples of an application embedded on Tuenti and that of an external website integrated with our platform to get started.

Documentation

In addition to the developer documentation available to trusted partners, complete documentation is provided with the SDK source code.

The following command, to be run from the base directory of the distribution, generates documentation in HTML format of all classes included in the SDK under the doc folder.

phpdoc -d src -t doc

Tests

The PHP SDK distribution includes a set of PHPUnit tests for ensuring its quality. A custom bootstrap is provided that must be run before the tests.

The following command, to be run from the base directory of the distribution, executes the full test suite and produces a code coverage report under the coverage folder.

phpunit --coverage-html coverage --stderr --bootstrap tests/bootstrap.php tests

Authors

  • Carlos Perez Arroyo
  • Einar Pehrson
  • Juan Jose Coello

License

Tuenti PHP SDK for Applications is available under the Apache License, version 2.0. See LICENSE for more information.

About

Tuenti PHP SDK for Applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%