gs2 / gs2-php-sdk
1.4.245
2024-09-26 08:33 UTC
Requires
- php: >= 8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.4.1
Requires (Dev)
- phpunit/phpunit: ^9
- dev-master
- 1.4.245
- 1.4.244
- 1.4.243
- 1.4.242
- 1.4.241
- 1.4.240
- 1.4.239
- 1.4.238
- 1.4.237
- 1.4.236
- 1.4.235
- 1.4.234
- 1.4.233
- 1.4.232
- 1.4.231
- 1.4.230
- 1.4.229
- 1.4.228
- 1.4.227
- 1.4.226
- 1.4.225
- 1.4.224
- 1.4.223
- 1.4.222
- 1.4.221
- 1.4.220
- 1.4.219
- 1.4.218
- 1.4.217
- 1.4.216
- 1.4.215
- 1.4.214
- 1.4.213
- 1.4.212
- 1.4.211
- 1.4.210
- 1.4.209
- 1.4.208
- 1.4.207
- 1.4.206
- 1.4.205
- 1.4.204
- 1.4.203
- 1.4.202
- 1.4.201
- 1.4.200
- 1.4.199
- 1.4.198
- 1.4.197
- 1.4.196
- 1.4.195
- 1.4.194
- 1.4.193
- 1.4.192
- 1.4.191
- 1.4.190
- 1.4.189
- 1.4.188
- 1.4.187
- 1.4.186
- 1.4.185
- 1.4.184
- 1.4.183
- 1.4.182
- 1.4.181
- 1.4.180
- 1.4.179
- 1.4.178
- 1.4.177
- 1.4.176
- 1.4.175
- 1.4.174
- 1.4.173
- 1.4.172
- 1.4.171
- 1.4.170
- 1.4.169
- 1.4.168
- 1.4.167
- 1.4.166
- 1.4.165
- 1.4.164
- 1.4.163
- 1.4.162
- 1.4.161
- 1.4.160
- 1.4.159
- 1.4.158
- 1.4.157
- 1.4.156
- 1.4.155
- 1.4.154
- 1.4.153
- 1.4.152
- 1.4.151
- 1.4.150
- 1.4.149
- 1.4.148
- 1.4.147
- 1.4.146
- 1.4.145
- 1.4.144
- 1.4.143
- 1.4.142
- 1.4.141
- 1.4.140
- 1.4.139
- 1.4.138
- 1.4.137
- 1.4.136
- 1.4.135
- 1.4.134
- 1.4.133
- 1.4.132
- 1.4.131
- 1.4.130
- 1.4.129
- 1.4.128
- 1.4.127
- 1.4.126
- 1.4.125
- 1.4.124
- 1.4.123
- 1.4.122
- 1.4.121
- 1.4.120
- 1.4.119
- 1.4.118
- 1.4.117
- 1.4.116
- 1.4.115
- 1.4.114
- 1.4.113
- 1.4.112
- 1.4.111
- 1.4.110
- 1.4.109
- 1.4.108
- 1.4.107
- 1.4.106
- 1.4.105
- 1.4.104
- 1.4.103
- 1.4.102
- 1.4.101
- 1.4.100
- 1.4.97
- 1.4.96
- 1.4.95
- 1.4.91
- 1.4.90
- 1.4.89
- 1.4.88
- 1.4.87
- 1.4.86
- 1.4.85
- 1.4.84
- 1.4.83
- 1.4.82
- 1.4.81
- 1.4.80
- 1.4.79
- 1.4.78
- 1.4.77
- 1.4.76
- 1.4.75
- 1.4.74
- 1.4.73
- 1.4.72
- 1.4.71
- 1.4.70
- 1.4.69
- 1.4.68
- 1.4.67
- 1.4.66
- 1.4.65
- 1.4.64
- 1.4.63
- 1.4.62
- 1.4.61
- 1.4.60
- 1.4.59
- 1.4.58
- 1.4.57
- 1.4.56
- 1.4.55
- 1.4.54
- 1.4.53
- 1.4.52
- 1.4.50
- 1.4.49
- 1.4.48
- 1.4.47
- 1.4.46
- 1.4.45
- 1.4.43
- 1.4.42
- 1.4.41
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.2.0
- 0.1.1
- 0.1.0
- 0.0.1
- dev-develop
This package is auto-updated.
Last update: 2024-09-26 08:34:14 UTC
README
gs2-php-sdk
Game Server Services(https://gs2.io) 是用于 PHP 的 SDK。
什么是 Game Server Services
Game Server Services(GS2) 是针对游戏开发的专业后端服务器服务(BaaS)。
GS2 是一个通用游戏服务器的解决方案,旨在提高游戏开发者的效率,并支持 Games as a Service(GaaS) 和 Live Gaming 等功能。
此服务允许灵活管理玩家数据和分析数据,可以适当地分析游戏内资源的流通和消耗量,从而维护健康的环境。此外,它还提供了故事进度管理、物品管理等功能,有助于游戏收益化和提高玩家参与度。GS2 支持在线功能,通过使开发者能够轻松进行数据分析和经济管理,从而支持游戏的成功。
入门指南
使用 SDK 需要GS2的凭证。请按照 GS2的设置 的说明步骤获取凭证。
运行条件
- PHP7.1+
示例
GS2-Account 示例
初始化处理
use Gs2\Account\Gs2AccountRestClient; use Gs2\Core\Model\BasicGs2Credential; use Gs2\Core\Model\Region; use Gs2\Core\Net\Gs2RestSession; $session = new Gs2RestSession( new BasicGs2Credential( "your client id", "your client secret" ), Region::AP_NORTHEAST_1 ); $session->open(); $client = new Gs2AccountRestClient( $session );
同步处理
use Gs2\Account\Model\ScriptSetting; use Gs2\Account\Request\CreateNamespaceRequest; use Gs2\Core\Exception\Gs2Exception; use PHPUnit\Framework\Assert; try { $result = $client->createNamespace( (new CreateNamespaceRequest()) ->withName('namespace-0001') ->withAuthenticationScript( (new ScriptSetting()) ->withTriggerScriptId('script-0001') ) ); Assert::assertNotNull($result->getItem()); Assert::assertEquals('namespace-0001', $result->getItem()->getName()); Assert::assertEquals('script-0001', $result->getItem()->getAuthenticationScript()->getTriggerScriptId()); } catch (Gs2Exception $e) { Assert::fail($e->getMessage()); }
异步处理
use Gs2\Account\Model\ScriptSetting; use Gs2\Account\Request\CreateNamespaceRequest; use Gs2\Account\Result\CreateNamespaceResult; use Gs2\Core\Exception\Gs2Exception; use PHPUnit\Framework\Assert; // 非同期処理をハンドリングするための Promise が返る $promise = $client->createNamespaceAsync( (new CreateNamespaceRequest()) ->withName('namespace-0001') ->withAuthenticationScript( (new ScriptSetting()) ->withTriggerScriptId('script-0001') ) )->then( function (CreateNamespaceResult $result) { // コールバック形式でハンドリングしたい場合は成功時のハンドラーをここに記述 Assert::assertNotNull($result->getItem()); Assert::assertEquals('namespace-0001', $result->getItem()->getName()); Assert::assertEquals('script-0001', $result->getItem()->getAuthenticationScript()->getTriggerScriptId()); }, function (Gs2Exception $e) { // コールバック形式でハンドリングしたい場合は失敗時のハンドラーをここに記述 Assert::fail($e->getMessage()); } ); try { // Promise を wait することで処理が実行される。戻り値には成功時の結果が返り、失敗時には例外が発生する。 $result = $promise->wait(); Assert::assertNotNull($result->getItem()); Assert::assertEquals('namespace-0001', $result->getItem()->getName()); Assert::assertEquals('script-0001', $result->getItem()->getAuthenticationScript()->getTriggerScriptId()); } catch (Gs2Exception $e) { Assert::fail($e->getMessage()); }
关于 Promise 的文档请参阅 https://github.com/guzzle/promises。
SDK 详细规格
有关各种服务和通信方式的详细信息,请参阅
。
由于本项目代码除 gs2-php-sdk-core 以外都是自动生成的,因此无法单独处理 Pull-Request。