# <font >  Get Key</font>
## Description
>To get a new key for player to launch game. Need to provide currency for the first login. System will create new account automatically if it does not exist

>request method:（Host -> BeSoft）:post ；

>encoding method：application/x-www-form-urlencoded

>Besoft format of the outgoing request data: application/json

##  Method URL
>{besoftapi}/api/game/getKey


##     Request Parameters
| Name    | Type     | Required    |     Description       | 
| -------- | -------- | -------- |    -------- |  
| cert     | string     |   Y |     security code |
| user      |string (30) |  Y |      unique user id (only allow lower case a-z and 0-9) BY WEBSITE）|
| extension1 | string(20) | Y |      Agent ID(Can be used for login, each proxy account can only be used for a single operator) |



## Example

- **URL**:
    - `http://127.0.0.1:8000/api/game/getKey`

- **HTTP Method**:
    - `POST`

- **Form Data**:
    > Content-Type: `application/x-www-form-urlencoded`
  
    ```
    cert: v8VMKKzlPpD0te4rX99Hgefs3PQrBFWJKiuUqg6Y
    user: test1
    extension1: adminweb
    ```
	
##     Return Result
| Name     | Type     | Description   |    
| -------- | -------- | -------- |   
| status   | string     | status code  |     
|key    |string | unique identifier token generated upon each login |     
|returnurl    |string |  Return the URL to log in to the game, with gid parameter required to specify the game for login|     


##    Successful Result

```
{
    "status": 1,
    "key": "50iD5lzhlTAJqJepJcz4PWohVW0uXYwhTtMeixqdsgcT4ErSso9i17i8AZ247kEZVHO4oVDloDgCjeAulbXT4I",
    "returnurl": "http://127.0.0.1:8000/?key=50iD5lzhlTAJqJepJcz4PWohVW0uXYwhTtMeixqdsgcT4ErSso9i17i8AZ247kEZVHO4oVDloDgCjeAulbXT4I"
}

```

##  Failed Result

> {“staus”:1001}


##    Login

###  Description
>Returnurl(provided by the getkey API) to invoke this method to start the game (with gid specifying a specific game and lang specifying the game language), where a player can only enter one game at a time and cannot simultaneously enter multiple games.

>Request method:（Host-> BesoftFront）:GET；

>Game return description: After the game is closed, the return address (return_url= the parameter of the return address), if not filled in, the game has no return button.

##    Method URL
```
http://{BesoftFront}/?key=3F6AE577A2E2255EF4BACF02C9F8BB1154A9C6AD2F19701568BA675BDA3C46BCA64D243007F87C86119329271708&gid=aa0001&lang=en&return_url=https://returnyoururl.com

```

> New interface: If you need to close the current window directly, please use the window.open mode to open, and do not need to pass the return_url


> New interface: If the parameter return_url is added, please encode the parameter in URLEncoding mode


> Embedded interface: If it is embedded, please listen for this message notification (closeMessage), the game manufacturer closes the game's call interface

```
{
   window.parent.postMessage("closeMessage", "*")
}

```



## Request Parameter

| Name     | Type    | Required    |   Description       | 
| -------- | -------- | -------- |    -------- |  
| key     |string(86) |  Y |Key value returned by “GetKey”Please do URLEncoding on it   while using the HTTP GET method |
| gid | string | Y |      Default launching game; if blank, go to lobby.  |
| lang | string | Y |      Default is cn;    cn: simplified Chinese      en : english |
| return_url | string | N |      return_url=Game off return address，Please encode the parameters in URLEncoding mode |
##     Return Result
{
    "status": 1,
    "key": "50iD5lzhlTAJqJepJcz4PWohVW0uXYwhTtMeixqdsgcT4ErSso9i17i8AZ247kEZVHO4oVDloDgCjeAulbXT4I",
    "returnurl": "http://127.0.0.1:8000/?key=50iD5lzhlTAJqJepJcz4PWohVW0uXYwhTtMeixqdsgcT4ErSso9i17i8AZ247kEZVHO4oVDloDgCjeAulbXT4I"
}
###  Successful Result

>Redirect Browser to game hall page

###  Failed Result

>The game interface displays the corresponding error message.

