Bank Inventory
概要
创建/更新/获取/删除游戏物品信息所需的 API。
信息
关于使用梦宝币对物品进行收费的详情,请同时参见教程。
Bank Inventory 对象字段
向Bank Inventory API 发送请求后,会反馈Bank Inventory 对象。
| 值 | 说明 | 类型 |
|---|---|---|
| id | 物品 ID | xs:string |
| name | 物品名 | xs:string |
| price | 物品价格 | xs:int |
| description | 物品说明 | xs:string |
| imageUrl | 物品图片的 URL | xs:string |
端点URL
Sandbox环境
https://sb-app.mobage.jp/social/api/restful/v2.02/bank/inventory/{appid}/{-list|,|itemId}
正式环境
https://app.mobage.jp/social/api/restful/v2.02/bank/inventory/{appid}/{-list|,|itemId}
API请求
HTTP 方法
- Authorization Code Grant
- GET 获取已注册的游戏物品列表。
- Client Credentials Grant
- GET 获取已注册的游戏物品列表。
- POST 创建游戏物品信息。
- PUT 更新游戏物品信息。
- DELETE 删除游戏物品信息。
API响应
| HTTP状态代码 | HTTP 状态信息 | 说明 |
|---|---|---|
| 200 | OK | 获取数据成功时 |
| 201 | Created | 数据获取已生成时 |
| 202 | Accepted | 数据获取已更新时 |
| 400 | Bad Request | 客户端的请求数据不当 |
| 401 | Unauthorized | 认证错误 |
| 403 | Forbidden | 资源存在,但由于认证错误以外的原因导致不能访问的情况 |
| 404 | Not Found | 资源不存在 |
| 500 | Internal Server Error | API 服务器端的错误 |
| 503 | Service Unavailable | API 暂时不可用时 |
样例
获取已注册的全部物品列表
请求格式
GET /social/api/restful/v2.02/bank/inventory/@app
响应格式
200 OK
{
"entry":[
{"id":"life_pack_1"},
{"id":"booster"}
],
"startIndex":1,
"sorted":false,
"itemsPerPage":2,
"updatedSince":false,
"totalResults":2,
"filtered":false
}
只获取指定的物品
请求格式
GET /social/api/restful/v2.02/bank/inventory/@app/booster,life_pack_1?fields=price,description
响应格式
200 OK
{
"entry":[
{
"id":"booster",
"price":200,
"description":"A booster that doubles your score immediately."
},
{
"id":"life_pack_1",
"price":100,
"description":"You got 3 life."
}
],
"startIndex":1,
"sorted":false,
"itemsPerPage":2,
"updatedSince":false,
"totalResults":2,
"filtered":false
}
生成物品信息
请求格式
POST /social/api/restful/v2.02/bank/inventory/@app
Authorization: Bearer eyJhbGciOiJSUzI1NiJ9
Content-Type: application/json; charset=utf-8
{
"id":"life_pack_2",
"name": "Sample Item2",
"price": 100,
"imageUrl": "http:\/\/mobage.com\/homepage-assets\/images\/icon.png",
"description": "This is a sample item"
}
响应格式
201 Created
更新物品信息
请求格式
PUT /social/api/restful/v2.02/bank/inventory/@app/life_pack_2?fields=price,imageUrl
Authorization: Bearer eyJhbGciOiJSUzI1NiJ9
Content-Type: application/json; charset=utf-8
{
"price": 350,
"imageUrl": "ttp:\/\/mobage.com\/homepage-assets\/images\/icon2.png",
}
响应格式
202 Accepted
删除物品信息
请求格式
DELETE /social/api/restful/v2.02/bank/inventory/@app/life_pack_2
Authorization: Bearer eyJhbGciOiJSUzI1NiJ9
Content-Type: application/json; charset=utf-8
响应格式
202 Accepted