This API is used to query the current login status of a user.
https://xxxxxx/v4/openim/query_online_status?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
The following is a list of the parameters commonly used when calling this API and their descriptions. For more parameters, see the RESTful API Overview.
Parameter | Description |
---|---|
https | The request protocol is HTTPS, and the request method is POST. |
xxxxxx | The country/region where your SDKAppID is located.console.tim.qq.com adminapisgp.im.qcloud.com adminapikr.im.qcloud.com adminapiger.im.qcloud.com adminapiind.im.qcloud.com adminapiusa.im.qcloud.com |
v4/openim/query_online_status | The request API that is used. |
sdkappid | The SDKAppID assigned via the IM console when the application is created. |
identifier | The value must be the app admin account. For more information, see App Admin. |
usersig | The signature generated by the app admin account. For more information on the operation, see Generating UserSig. |
random | The value must be a random 32-bit unsigned integer. Value range: 0 to 4294967295. |
contenttype | Request format. The value is always json . |
This API can be called up to 200 times per second.
{
"To_Account":["id1","id2","id3","id4"],
}
{
"IsNeedDetail": 1,
"To_Account": ["id1", "id2", "id4"]
}
Field | Type | Property | 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"
}
],
"ErrorList": [
{
"To_Account": "id4",
"ErrorCode": 70107
}
]
}
{
"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",
}
],
"ErrorList": [
{
"To_Account": "id4",
"ErrorCode": 70107
}
]
}
{
"ActionStatus": "FAIL",
"ErrorInfo": "Fail to Parse json data of body, Please check it",
"ErrorCode": 90001
}
Field | Type | Description |
---|---|---|
ActionStatus | String | The processing result of the request. OK: succeeded. FAIL: failed. |
ErrorInfo | String | Detailed information on the error. |
ErrorCode | Integer | The error code returned for the request. |
QueryResult | Array | The returned structured information of the login status of the user. |
QueryResult.To_Account | String | The UserID of the user whose status is returned. |
QueryResult.Status | String | The returned login status. Valid values:
|
QueryResult.Detail | Object | The detailed information on the login platform. |
QueryResult.Detail.Platform | String | The type of the login platform. Valid values: "iPhone", "Android", "Web", "PC", "iPad", and "Mac". |
ErrorList | Array | The list of accounts whose statuses failed to be queried. The target accounts in this list were not found or their statuses failed to be queried. If the status query for all accounts succeeded, the value of the ErrorList field is blank. |
ErrorList.To_Account | String | The target account whose status failed to be queried. |
ErrorList.ErrorCode | Integer | The error code indicating that the status query failed. If the error code for a target account is 70107, the account was not found. |
Note:The IM backend stores the PushOnline state for only 7 days. If a user has not logged in to the client within 7 days since the previous login, the user enters the Offline state.
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 public error codes 60000 to 79999, see Error Codes.
The private error codes for this API are as follows:
Error Code | Description |
---|---|
70107 | The requested UserID does not exist. |
70169 | The server timed out. Try again later. |
90001 | JSON format parsing failed. Check whether the request packet meets the JSON specification, or whether To_Account is a null 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 request requires the app admin’s permissions. |
90011 | The number of target accounts to which the message is to be sent exceeds 500. Reduce the number of target accounts in To_Account. |
90992 | The backend service timed out. Please try again. |
90994 | An internal service error occurred. Please try again. |
90995 | An internal service error occurred. Please try again. |
91000 | An internal service error occurred. Please try again. |
To debug this API, you can use the Online RESTful API Debugging Tool.
Was this page helpful?