Sharesome SDK for PHP

We provide a easy to use library for accessing the Sharesome API and taking advantage of Sharesome Login.

1. Installing the Sharesome PHP SDK

There are two methods to install the Sharesome PHP SDK. The easiest installation method is by using Composer. If are unable to use Composer for your project, you can still install the SDK manually by downloading the source files and including the library.

Installing via Composer (Recomended)

To install the Sharesome PHP SDK with Composer simply add the following entry to the composer.json file in the root of your project to the "reqiure" section.

{
  "require" : {
    "pornfyre/php-sdk-v1" : "dev-master"
  }
}

Run the composer install from the command line, and composer will download the latest version of the SDK and put it in the /vendor/ directory.
If there is no composer.json in your project you can use composer require pornfyre/php-sdk-v1 dev-master command in your app folder.

Make sure to include the Composer autoloader form the /vendor/ folder at the top of your script.

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

Download the SDK (Only if necessary)

Use the button below to download the archive that contains the SDK and all the dependinces.

Download SDK

Load the SDK

To load the SDK please include the pornfyre.php file like this:

require __DIR__ . '/path/to-pornfyresdk/pornfyre.php';

2. Configuration and setup

Instantiate the Sharesome class

After inlcuding the file, the Sharesome class must be instantiated with an array containing the following data: app_id, app_secret and redirect_uri.

$pornfyre = new Sharesome([
  'app_id'=> APP Client ID,
  'app_secret'=> APP Client Secret,
  'redirect_uri'=> APP Authorization callback URL
]);

Execute the redirect

After instantiation the redirect should be called, this will make the request for the OAuth token and redirect back to callback URL.

$pornfyre->redirect();

In callback file / section get the user data and save / login

At the callback, if no error is returned, we will make a request to get the user info. See REST API Documentation for more details about the data returned for an user.

if( !isset($_GET['error']) ){

  $user = $pornfyre->user();

  // Insert the user in database
  // Login the user
  // Redirect

} else {
  echo $_GET['error_description'];
}