This API is used to query the current login status of a user.
https://console.tim.qq.com/v4/openim/querystate?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
The following table lists and describes only the parameters to be modified when this API is called. For more parameters, see REST API Overview.
Parameter | Description |
---|---|
v4/openim/querystate | Request API. |
sdkappid | The SDKAppID assigned by the Instant Messaging (IM) console when the application is created. |
identifier | The value must be the administrator account of the app. For more information, see App Administrator. |
usersig | The signature generated for the administrator account of the app. For more information about the operation, see Generating UserSig. |
random | The value can be a random 32-bit unsigned integer. Value range: 0 to 4294967295. |
This API can be called up to 200 times per second.
{
"To_Account": ["id1", "id2", "id3"]
}
{
"IsNeedDetail": 1,
"To_Account": ["id1", "id2"]
}
Field | Type | Required | Description |
---|---|---|---|
To_Account | Array | Required | The one or more UserIDs whose login statuses are to be queried. This API can be used to query the login statuses of up to 500 UserIDs at a time. |
IsNeedDetail | Integer | Optional | Specifies whether detailed login platform information is needed in the response. 0: Not needed; 1: Needed. |
{
"ActionStatus": "OK",
"ErrorInfo": "",
"ErrorCode": 0,
"QueryResult": [
{
"To_Account": "id1",
"State": "Offline"
},
{
"To_Account": "id2",
"State": "Online"
},
{
"To_Account": "id3",
"State": "PushOnline"
}
]
}
{
"ActionStatus": "OK",
"ErrorInfo": "",
"ErrorCode": 0,
"QueryResult": [
{
"To_Account": "id1",
"State": "Online",
"Detail": [
{
"Platform": "IPhone",
"Status": "PushOnline"
},
{
"Platform": "Web",
"Status": "Online"
}
]
},
{
"To_Account": "id2",
"State": "Offline",
}
]
}
{
"ActionStatus": "FAIL",
"ErrorInfo": "Fail to Parse json data of body, Please check it",
"ErrorCode": 90001
}
Field | Type | Description |
---|---|---|
ActionStatus | String | Processing result of the request. OK: successful; FAIL: failed. |
ErrorCode | Integer | Error code. Valid values: 0: successful; Non-zero: failed. |
ErrorInfo | String | Detailed information about the error. |
QueryResult | Array | The returned structured information of the login status of the user. |
To_Account | String | The returned UserID of the user whose login status is queried. |
State | String | The returned login status. Valid values:
|
Detail | Object | Detailed login platform information. |
Platform | String | The type of the login platform. |
Status | String | The status of the login platform. |
Note:
The IM backend stores the PushOnline status for only 7 days. If a user has not logged in to the client for 7 days since disconnection, the client enters the Offline status.
The HTTP return code for this API is 200 unless an network error such as error 502 occurs. The actual error code and error information are indicated by ErrorCode and ErrorInfo respectively in the response packet body.
For common error codes 60000 to 79999, see Error Codes.
The private error codes for this API are as follows:
Error Code | Description |
---|---|
90001 | Failed to parse the JSON format. Please check whether the request packet meets the JSON specifications, or whether the value of the To_Account field is an empty array. |
90003 | The value of the To_Account field in the JSON format request packet does not meet the message format requirements. Please check whether the type of the To_Account field is String. |
90009 | The administrator permissions of the app are required for the request. |
90011 | The number of target accounts for batch message delivery exceeds 500. Please decrease the value of the To_Account field. |
90992 | The backend service timed out. Please try again. |
90994 | Internal service error. Please try again. |
90995 | Internal service error. Please try again. |
91000 | Internal service error. Please try again. |
To debug this API, you can use the Online REST API Debugging Tool.
Was this page helpful?