You can call this method to import historical group messages in chronological order from another instant messaging service to ZEGOCLOUD Instant Messaging (ZIM).
The following table describes only the method-specific request parameters and some common request parameters. For the complete list of common request parameters, see Accessing Server APIs.
Parameter | Type | Required | Description |
---|---|---|---|
FromUserId |
String |
Yes |
The ID of the message sender (registered). |
GroupId |
String |
Yes |
The group ID. |
MessageType |
Number |
Yes |
Message type. For more information about message types applicable to a group chat, see MessageBody Introduction. Signaling messages are not supported. |
Priority |
Number |
Yes |
Message priority. Valid values:
|
MessageBody |
Object |
Yes |
Message content. For more information about the format, see MessageBody Introduction. Offline push is not supported. |
SubMsgType |
Number |
No (Yes if MessageType is 200 ) |
Custom message type. Value range: [0,200]. |
SearchedContent |
String |
No |
The searched content of the custom message. This field is required only if MessageType is 200 and can contain up to 64 bytes in length. This field is required to search for associated custom messages on the client. |
SendMessageTime |
Number |
No |
The Unix timestamp when the message was sent. Unit: ms. Import messages based on their sending timestamps in chronological order.
|
The FromUserId
and GroupId
parameters can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ' ', '{', '}', '|', '~'.
MessageType
is 1
, the version of the receiving ZIM SDK needs to be 2.7.0 or later.MessageType
is 200
, the version of the sending and receiving ZIM SDKs needs to be 2.8.0 or later.Request URL:
https://zim-api.zego.im/?Action=ImportGroupMsg
&<Common request parameters>
Request body:
{
"FromUserId": "u1",
"GroupId": "r1",
"MessageType": 1,
"Priority": 1,
"MessageBody": {
"Message": "hello world",
"ExtendedData": "d"
},
"SubMsgType": 200,
"SearchedContent": "ex",
"SendMessageTime": 123
}
Parameter | Type | Description |
---|---|---|
Code |
Number |
The return code. |
Message |
String |
The description of the request result. |
RequestId |
String |
The request ID. |
MsgSeq |
Number |
The message sequence. |
{
"Code": 0,
"Message": "success",
"RequestId": "343649807833778782",
"MsgSeq": 123
}
After messages are imported successfully, call the ZIM server API Query the message list of group chats
to check whether all group messages are imported.
The following table describes only the return codes related to the business logic of the method. For the complete list of return codes, see Return codes.
Return code | Description | Solution |
---|---|---|
660400001 |
The message size exceeds the limit. |
Check the message size. |
660500002 |
The message sender has not logged in to the ZIM SDK. |
Log in first. |
660600001 |
The GroupId does not exist. |
Check whether the value of the GroupId parameter is valid. |