Player Link API
注意
从2017/03/15 起,允许应用软件首次启动以外的数据继承。
概要
用于保存玩家绑定的应用软件内用户 ID(InAppUserId)的 API 。
认****可方法
为了使用该 API ,需要在Authorization 请求头中指定表中所示按 grant_type, scope 获取的 access token 。
- 认可类型
- Bearer
- 支持的 grant_type
- client_credentials_grant
- 需要的 scope
- player.links:authorizedUsers:write
终点 URL
各环境中的终点 URL 如下所述。
| item | description |
|---|---|
| HTTP Method | POST |
| Request URI | sandbox java https://sb-api.andapp.jp/1.0.0/users{/playerId}/link 正式环境 java https://api.andapp.jp/1.0.0/users{/playerId}/link |
请求示例
请求示例如下。
POST /1.0.0/users/4503599627370495/link HTTP/1.1
Host: sb-api.andapp.jp:443
Authorization: Bearer {access_token}
Content-Type: application/x-www-form-urlencoded
idp=app&id=12345
请求正文
可设置带有下述参数的请求参数。
| property | title | type | required | description |
|---|---|---|---|---|
idp | 关联识别名 | string | true | 通过app 固定 |
id | InAppUserId | string | true | 指定希望与玩家绑定的应用软件内部用户 ID(InAppUserId) |
响应状态
成功时的响应状态如下。
| status | description |
|---|---|
| 200 OK | 可正常反馈资源时,反馈此项。 |
响应头
响应头如下。
| name | value | required | description |
|---|---|---|---|
| Content-Type | application/json | true |
响应正文
响应正文为带有下述参数的 JSON 字符串。详见下述示例。
| property | title | type | required | description |
|---|---|---|---|---|
id | 玩家 ID | integer | true | 该玩家的 Player ID 。 |
links | IdP 关联对象 | object | true | 表示与该玩家关联的外部 Identity Provider 类别的对象。 |
| links.app | InAppUser 关联对象 | object | false | 该玩家有InAppUser ID 时的存在对象。 |
| links.app.id | InAppUserID | string | true | 设置在玩家中的 InAppUserId (应用特有 ID) 。 |
| links.app.createdAt | InAppUserId 设置开始时间 | integer | true | 应用软件内部用户 ID(InAppUserId)的设置时间。 |
| links.app.updatedAt | InAppUserId 设置更新时间 | integer | true | 已设置的应用软件内部用户 ID(InAppUserId)的更时间。 |
| links.mobage | Mobage 关联对象 | object | false | 该玩家有 Mobage 关联时的存在对象。 |
| links.mobage.createdAt | 关联开始时间 | integer | true | 该玩家开始 Mobage 关联的时间的UNIX 时间戳值。 |
| links.mobage.updatedAt | 关联更新时间 | integer | true | |
| createdAt | 创建时间 | integer | true | 该资源的创建时间的UNIX 时间戳值 |
| updatedAt | 更新时间 | integer | true | 该资源的更新时间的UNIX 时间戳值 |
响应示例(有****IdP 关联的示例)
HTTP/1.1 200 OK
Content-Type: application/json
{
"createdAt": 1485255409,
"id": 4503599627370495,
"links": {
"app": {
"createdAt": 1485497186,
"id": "12345",
"updatedAt": 1485502361
},
"mobage": {
"createdAt": 1439726867,
"updatedAt": 1439726867
}
},
"updatedAt": 1485502361
}
响应示例(无****IdP 关联的示例)
HTTP/1.1 200 OK
Content-Type: application/json
{
"createdAt": 1485255409,
"id": 4503599627370495,
"links": {
"app": {
"createdAt": 1485497186,
"id": "12345",
"updatedAt": 1485502361
}
},
"updatedAt": 1485502361
}
错误响应
错误响应以application/problem+json 形式发出。状态代码和 Problem Type 的 type 属性值如下。
| status | title | type | description |
|---|---|---|---|
| 400 | Bad Request | about:blank | 在URI Template 参数中指定了非法的 Player ID 时,反馈此项 |
| 404 | Not Found | about:blank | 在URI Template 参数中指定了不存在的 Player ID 时,反馈此项 |
| 409 | Conflict | about:blank | 试图绑定的应用软件内部用户 ID(InAppUserId)已与其他有梦宝谷关联的 AndApp 用户绑定时,反馈此项 请提示必须对该错误进行处理并在新游戏或其他 InAppUserID 中继承。 |
| 422 | TARGET HAS ONCE LINKED MBGA | about:blank | 试图绑定的应用软件内部用户 ID(InAppUserId)已与其他有IdP 关联的玩家 ID 绑定时,反馈此项。 |
| 500 | Server Error | about:blank | API 服务器端发生错误时,反馈此项 |
| 503 | Service Unavailable | about:blank | API 服务器暂时不能响应时,反馈此项 |
错误响应示例
错误响应示例如下。
指定的 Player ID 不存在时
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
{
"type": "about:blank",
"title": "Not Found",
"code": 404,
"instance": "https://sb-api.andapp.jp/1.0.0/users/4503599627370495/link"
}
试图绑定的应用软件内部用户 ID(InAppUserId)已与其他有梦宝谷关联的 AndApp 用户绑定
HTTP/1.1 409 Conflict
Content-Type: application/problem+json
{
"type": "https://problems.andapp.jp/1.0.0/common/409/conflict",
"title": "Conflict",
"status": 409,
"detail": "cannot process request with the link object because it has been locked by an other player",
"instance": "https://sb-api.andapp.jp//1.0.0/users/5392399203303424/link"
}
试图绑定的应用软件内部用户 ID**(InAppUserId)曾经其他与有** IdP 关联的玩家 ID 绑定
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/problem+json
{
"type": "https://problems.andapp.jp/1.0.0/users/422/target_has_once_linked_mbga",
"title": "TARGET HAS ONCE LINKED MBGA",
"status": 422,
"detail": "target has once linked mbga",
"instance": "https://sb-api.andapp.jp//1.0.0/users/5392399203303424/link"
}
更新履历
- 2017/07/04
- 应记载422 的多处部位记载有误,故更正。
- 2017/03/15
- Player Link API 的反应有更改,故删改
- 2017/02/15
- 新建