User Info
When a game runs inside the Lobah APP, the APP automatically appends user information to the URL for the game to read. Below is an example of the parameters appended:
index.html?gameId=906&uid=2111265&userId=2111265&sessionId=10102651744178667593&token=1c83bd22489b24bb84d20c6d758e9c8e&language=en&zone=sa&country=SA&version_name=1.10.0250409120005&login_type=google&appChannel=lobah1
Partial parameter descriptions:
| Parameter Name | Description |
|---|---|
| gameId | Game ID |
| uid | User ID |
| sessionId | Room ID |
| token | Verification token |
| appChannel | lobah |
Therefore, within the game, you can use the following JavaScript code to obtain user information:
javascript
function getUrlParams() {
const hash = window.location.hash
const url = window.location.search || hash.slice(hash.indexOf('?'))
const obj = {}
const reg = /[?&][^?&]+=[^?&]+/g
const arr = url.match(reg)
if (arr) {
arr.forEach(function (item) {
const tempArr = item.substring(1).split('=')
const key = decodeURIComponent(tempArr[0])
obj[key] = decodeURIComponent(tempArr[1])
})
}
return obj
}
const params = getUrlParams()
params.gameId // Game ID
params.uid // User ID
params.sessionId // Room ID
params.token // token1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21