User Information
When a game runs within the GameTok APP, the APP automatically appends user information to the URL for the game to read. Here's an example of the appended parameters:
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=lobah
1
Parameter Description
Description of some parameters:
Parameter Name | Description |
---|---|
gameId | Game ID |
uid | User ID |
sessionId | Room ID |
token | Authentication Token |
appChannel | lobah (Channel ID) |
Sample Code for Getting Parameters
Developers can retrieve URL parameters within the game using the following JavaScript code:
javascript
function getUrlParams() {
const queryString = window.location.search ||
(window.location.hash.includes('?') ? window.location.hash.substring(window.location.hash.indexOf('?')) : '')
const params = {}
if (queryString) {
queryString.slice(1).split('&').forEach(pair => {
if (pair) {
const [key, ...valueParts] = pair.split('=')
try {
params[decodeURIComponent(key)] = valueParts.length
? decodeURIComponent(valueParts.join('='))
: ''
} catch (e) {
console.warn('Failed to decode parameter:', pair)
}
}
})
}
return params
}
// Usage example
const params = getUrlParams()
// Get specific parameters
const gameId = params.gameId // Game ID
const uid = params.uid // User ID
const sessionId = params.sessionId // Room ID
const token = params.token // Authentication Token
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Frequently Asked Questions
Q: What should I do if parameters are missing?
A: Please ensure the game is opened normally through the GameTok APP. If parameters are abnormal, please contact platform support.Q: How long is the token valid?
A: The token validity period is related to the user's login status. It's recommended to validate the token every time you enter the game.