Admin Panel

PHP

SCILL provides a PHP class that maps REST-APIs and provides convenience functions.

Source Code

You can find the source code to our PHP SDK in our public Github repository: https://github.com/scillgame/scill-php. If you encounter any bugs or issues, please let us know in the Issues tab of Github.

Install PHP library

Easiest way to install PHP library is by using composer:

composer require scillgame/scill-php

Usage

This example shows how to set up an instance of the SCILLClient class by providing an API key and then sending an event using the convenience function sendEvent.

<?php

require_once('./vendor/autoload.php');

$scillClient = new \SCILL\SCILLClient('XnY,-AV+7dNGwrp!fVmP;96xAZ~,sqXJ]]8Htd4U[F');

try {
    $result = $scillClient->sendEvent('instant-death', '12345', '1234', array(
        "amount" => 1
    ));
} catch(\SCILL\ApiException $exception) {
    echo("Error: ".$exception->getMessage());
}

//$result = $scillClient->getEventsClient()->sendEvent($payload)->getStatus();
echo($result->getStatus());

Loading challenges requires an access token that needs to be created beforehand for the specific user. More info on that can be found in the API Reference.

<?php

require_once('./vendor/autoload.php');

// This is the App ID and API Key of our example app
$appId = "597737952688570369";
$scillClient = new \SCILL\SCILLClient('XnY,-AV+7dNGwrp!fVmP;96xAZ~,sqXJ]]8Htd4U[F');

// Create an instance of the auth api and create an access token for the user 1234
try {
    $authApi = $scillClient->getAuthClient();
    $id = new \SCILL\Model\ForeignUserIdentifier(array(
    	"user_id" => "1234"
    ));
    $auth = $authApi->generateAccessToken($id);
    $accessToken = $auth->getToken();
} catch(\SCILL\ApiException $exception) {
    echo("Error: ".$exception->getMessage());
}

// Load available challenges for this user
try {
    $challengesApi = $scillClient->getChallengesClient($accessToken);
    $categories = $challengesApi->getPersonalChallenges($appId);
    foreach ($categories as $category) {
        echo("Category: ".$category->getCategoryName()."\n");
        foreach($category->getChallenges() as $challenge) {
            echo("Challenge: ".$challenge->getChallengeName()."\n");
        }
    }
} catch(\SCILL\ApiException $exception) {
    echo("Error: ".$exception->getMessage());
}

Examples

Example code is provided in our public Github-Repository: