Skip to content

WrapItDev/php-sdk

Repository files navigation

WrapIt SDK for PHP

Build Status Code Coverage Packagist

Installation

The WrapIt SDK can be installed with Composer. Run this command:

composer require wrapit/php-sdk

Usage

Simple GET example to get data of a user profile

$wi = new \WrapIt\WrapIt([
    'domain' => '{domain}',
    'client_id' => '{client-id}',
    'client_secret' => '{client-secret}'
]);

// Use the LoginHelper to get an AccessToken

$userhelper = new \WrapIt\Helpers\WrapItUserHelper($wi, "{access-token}");

try {
    // Get data from the /people/me api
    $user = $userhelper->getUserData("me");
} catch (\WrapIt\Exceptions\WrapItResponseException $e) {
    echo 'The API returned an error: ' . $e->getMessage();
    exit;
}

echo 'Logged in as ' . $user["name"];