承接 harrk/gamejolt-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

harrk/gamejolt-api

最新稳定版本:2.1.0

Composer 安装命令:

composer require harrk/gamejolt-api

包简介

A PHP library for the Game Jolt API.

README 文档

README

CircleCI

https://gamejolt.com

This library provides full (except batching) coverage of Game Jolt's API (Trophies, Scores, Sessions, etc...) At the moment this library is written and tested for v1.2 of Game Jolt's API.

Installation

$ composer require "harrk/gamejolt-api"

Usage

Create an instance of GamejoltApi and provide a GamejoltConfig to begin making API calls to Game Jolt.

$gameId = 0; // Your game's ID
$gamePrivaykey = "Your game's private key";

$api = new GamejoltApi(new GamejoltConfig(
    $gameId,
    $gamePrivaykey
));

Endpoints

Below are examples of how you would interact with each endpoint. Bare in mind that these are only examples, and may not use all parameter options.

Refer to the Game Jolt API Documentation or the source code for more options.

Data Store

The Data Store API can be used to store/retrieve data in the cloud.

// 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();

Friends

The Friends API can only be used to find the friend IDs of the user currently.

// Fetch all friend ids for the user
$api->friends()->fetch('username', 'user-token');

Scores

//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);

Sessions

//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');

Time

//Get GJ's server time
$api->time()->fetch();

Trophies

//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);

Users

//Fetch data on user
$api->users()->fetch('username', 'user_token');

//Verify if the user's credentials are correct
$api->users()->auth('username', 'user_token');

Catching Exceptions

Here is a example on how to catch exceptions:

try {
    $auth = $api->users()->auth('username', 'user_token');
} catch (TimeOutException $e) {
    return redirect()->route('home')->with('error', $e->getMessage());
}

Testing

Two commands have been provided to simplify the running of tests.

Run Unit Tests

$ composer test

Run Static Code Analysis

$ composer analyse

Todo

  • Allow POST method on endpoints
  • Increase coverage of Unit Tests

License

MIT License

统计信息

  • 总下载量: 2.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固