spinshield / spinclient
1.0.7
2024-06-16 21:35 UTC
Requires
- php: >=5.3.0
- guzzlehttp/guzzle: >=7.0.0
README
为了帮助使用PHP的操作员更容易地集成。适用于任何PHP > 5,需要GuzzleHttp。
您可以将此包用于现有的基于PHP的项目中。这包括任何基于PHP的框架,如Laravel、Lumen、Yiii等。
安装
在您的PHP项目中运行:composer require spinshield/spinclient
功能概述
API客户端功能
// e.g. getGame("player123", "playerPass123", "platipus/egyptiangold", "USD", "https://casino.com", "https://casino.com/deposit", 0, "en"); getGame($username, $userpassword, $game_id, $currency, $homeurl, $cashierurl, $play_for_fun, $lang); // e.g. getGameDemo("platipus/egyptiangold", "USD", "https://casino.com", "https://casino.com/deposit", "en"); getGameDemo($game_id, $currency, $homeurl, $cashierurl, $lang); // e.g. getGameList("USD", 1); getGameList($currency, $list_type); // e.g. createPlayer("player123", "playerPass123", "Malone", "USD"); createPlayer($username, $userpassword, $usernickname, $currency); // e.g. addFreeRounds("player123", "playerPass123", "platipus/egyptiangold", "USD", 10, 0); addFreeRounds($username, $userpassword, $game_id, $currency, $freespins, $betlevel); // e.g. getFreeRounds("player123", "playerPass123", "USD"); getFreeRounds($username, $userpassword, $currency); // e.g. deleteFreeRounds("platipus/egyptiangold", "player123", "playerPass123", "USD"); deleteFreeRounds($gameid, $username, $userpassword, $currency); // e.g. deleteFreeRounds("player123", "playerPass123", "USD"); deleteAllFreeRounds($username, $userpassword, $currency);
辅助功能
此包还包括辅助函数,帮助您在回调中返回响应。请参见以下示例如何实现。
回调辅助函数
// validate the callback request coming from our gameserver, take 'key', 'timestamp' from each callback and salt from your apikey configuration in backoffice isValidKey($key, $timestamp, $salt); // construct balance response in JSON format balanceResponse($intBalance); // construct insufficient balance in JSON format insufficientBalance($intBalance); //construct generic error reponse (when you have error processing callback) in JSON format processingError();
通用辅助函数
// check for error code on api responses responseHasError($apiResponse); // morphs json object to associative array morphJsonToArray($input); // because our API communicates using int value in cents, this can assist you to convert for example ($) 2.00 to 200 securely floatToIntHelper($floatValue); // converts int back to float (2 decimals) intToFloatHelper($intValue);
示例
PHP使用示例
<?php use spinshield/spinclient; require __DIR__.'/vendor/autoload.php'; $client = new spinclient\ApiClient(array( "endpoint" => "https://secretendpoint.com", "api_login" => "12345", "api_password" => "12345", )); var_export($client->getGamesList("USD", 1));
Laravel使用示例
routes/web.php
Route::get('/spinshield_example/gamelist', [\App\Http\Controllers\SpinController::class, 'gamelist']); Route::get('/spinshield_example/gameflow', [\App\Http\Controllers\SpinController::class, 'gameflow']);
app/Http/Controllers/SpinController.php
<?php namespace App\Http\Controllers; use spinshield\spinclient; class SpinController { function __construct() { $this->client = new spinclient\ApiClient(array( "endpoint" => "https://secretendpoint.net", "api_login" => "12345", "api_password" => "12345", )); $this->helpers = new spinclient\Helpers(); } public function gamelist() { return $this->client->getGameList("USD", 1); } public function gameflow() { $createPlayer = $this->client->createPlayer("playerId1337", "playerPassword", "Tiernan", "USD"); if($this->helpers->responseHasError($createPlayer)) { return $createPlayer; } else { $getGame = $this->client->getGame("playerId1337", "playerPassword", "platipus/egyptiangold", "USD", "https://casino.com", "https://casino.com/deposit", 0, "en"); return $getGame; } } }