1. Go to this page and download the library: Download harrk/gamejolt-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
harrk / gamejolt-api example snippets
$gameId = 0; // Your game's ID
$gamePrivaykey = "Your game's private key";
$api = new GamejoltApi(new GamejoltConfig(
$gameId,
$gamePrivaykey
));
// Fetch the value for my-key
$api->dataStore()->fetch('my-key');
// Set the value for my-key to my-value
$api->dataStore()->set('my-key', 'my-value');
// Update player-logins by 1
$api->dataStore()->update('player-logins', DataStore::OPERATION_ADD, 1);
// Remove my-key
$api->dataStore()->remove('my-key');
// Fetch all keys
$api->dataStore()->getKeys();
// Fetch all friend ids for the user
$api->friends()->fetch('username', 'user-token');
//Fetch scores
$api->scores()->fetch();
//Fetch all score tables
$api->scores()->tables();
//Add a gamejolt user's score to the table
$api->scores()->addUserScore('username', 'user_token', '100 Jumps', 100);
//Add a guest's score to the table
$api->scores()->addGuestScore('Mr Guest', '50 jumps', 50);
//Get score rank
$api->scores()->getRank(60);
//Open a session for the given user
$api->sessions()->open('username', 'user_token');
//Let GJ know the user session is still active
$api->sessions()->ping('username', 'user_token', Sessions::STATUS_ACTIVE);
//Check if the session is still open for user
$api->sessions()->check('username', 'user_token');
//Close the session for user
$api->sessions()->close('username', 'user_token');
//Get GJ's server time
$api->time()->fetch();
//Get all trophies
$api->trophies()->fetch('username', 'user_token');
//User has achieved a trophy with ID 1
$api->trophies()->addAchieved('username', 'user_token', 1);
//User unachieved trophy with ID 1
$api->trophies()->removeAchieved('username', 'user_token', 1);
//Fetch data on user
$api->users()->fetch('username', 'user_token');
//Verify if the user's credentials are correct
$api->users()->auth('username', 'user_token');