Obtain a game start code
Description
To start a live comment-based game on the PC side, this interface must be called before the game starts. Enter the anchor, room, and game information and receive a unique game activation code.
The game activation code is time-sensitive and will become invalid after it expires. It is recommended that the host obtains the game activation code via this interface each time before starting the game. ZEGOCLOUD guarantees that the received game activation code can be used at least once within 2 hours.
Once the game has started, do not call this interface again to get a new start code, otherwise the current game may be forcibly terminated. Whether the game is forcibly terminated depends on the game. It is recommended that this only be called when starting to play or switching between games.
Request method and endpoint
- Request method: POST
- Request URL:
https://mini-game-api.zego.im/?Action=DescribeGameLaunchCode
- Transfer protocol: HTTPS
- Call frequency limit: 20 times/second (taking the room as the dimension)
Request parameters
The following request parameter list only lists interface request parameters. Please refer to Make API requests for the public parameter list.
Parameter | Type | Is it required? | Description |
---|---|---|---|
RoomId | String | Yes | Room ID, defined by you, with a maximum length of 64 characters. |
MiniGameId | String | Yes | Game ID, please contact the ZEGOCLOUD technical support team to obtain relevant content. |
AnchorId | String | Yes | Anchor ID, defined by you, with a maximum length of 48 characters, only allowing numbers and English letters. |
Nickname | String | Yes | Anchor nickname, defined by you, with a maximum length of 32 characters. |
Avatar | String | Yes | The address of the anchor's avatar must be a valid HTTP/HTTPS address and have a length of no more than 1024 bytes. |
Sex | int | No | Anchor gender.
|
Request example
-
Request URL
Untitledhttps://mini-game-api.zego.im/?Action=DescribeGameLaunchCode &<Common request parameters>
1 -
Request message body
Untitled{ "RoomId": "room_123", "MiniGameId": "TinyLoveWar", "AnchorId": "anchor1", "Nickname": "anchor", "Avatar": "http://xxx", "Sex": 1 }
1
Response parameters
Parameter | Type | Description |
---|---|---|
Code | Number | Error code. |
Message | String | Description of the request result. |
RequestId | String | Request ID. |
Data | Object | Response object. |
GameLaunchCode | String | Game activation code. |
Response example
{
"Code": 0,
"Message": "succeed",
"RequestId": "abcd123",
"Data": {
"GameLaunchCode":1011001,
}
}
Return code
Only the return codes related to the interface business logic are listed below. For complete return codes, please refer to Global return codes.
Return code | Description | Handling suggestions |
---|---|---|
7202001 | The game was not found. Possible reasons include:
|
|
7202002 | MiniGameId wrong format. | Please confirm whether the format is String. |
7206004 | The room is already occupied by another host. | Please confirm whether the AnchorId passed in is consistent with the room owner. |
7206005 | Obtaining game codes too frequently. | Please try again later. |