Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

trophyso/trophy-php

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trophy PHP SDK

The Trophy PHP SDK provides convenient access to the Trophy API from applications written in PHP.

Trophy provides APIs and tools for adding gamification to your application, keeping users engaged through rewards, achievements, streaks, and personalized communication.

Installation

You can install the bindings via Composer. Run the following command:

composer require trophyso/php

To use the bindings, use the Composer's autoload:

require_once('vendor/autoload.php');

Usage

The package needs to be configured with your account's API key, which is available in the Trophy web interface. Set the API key with the following:

use Trophy\TrophyClient;
use Trophy\Metrics\Requests\MetricsEventRequest;
use Trophy\Types\EventRequestUser;

$trophy = new TrophyClient('your-api-key');

Then you can access the Trophy API through the $trophy client. For example, you can send a metric event:

// Create a new user object
$user = new EventRequestUser([
    'id' => '18',
    'email' => 'jk.rowling@harrypotter.com'
]);

// Create a new MetricsEventRequest object
$request = new MetricsEventRequest([
    'user' => $user,
    'value' => 750
]);

// Send the event to the Trophy API
$trophy->metrics->event("words-written", $request);

Documentation

See the Trophy API Docs for more information on the accessible endpoints.

Releases

No releases published

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.