定制 harrk/gamejolt-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

harrk/gamejolt-api

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

harrk/gamejolt-api 适用场景与选型建议

harrk/gamejolt-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.59k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2019 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「api」 「composer」 「game」 「jolt」 「Gamejolt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 harrk/gamejolt-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 harrk/gamejolt-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 harrk/gamejolt-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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