Callback After Agreeing to Add a Friend
Function Description
The App backend can use this callback to real-time monitor the addition of new friends by users.
Precautions
- To enable the callback, it is necessary to configure the callback URL and activate the corresponding switch for this callback protocol. Configuration methods can be found in the Callback Explanation document.
- The direction of the callback is an HTTP/HTTPS POST request initiated by OpenIM Server to the App backend.
- After receiving the callback request, the App business server must verify whether the command parameter in the request URL is its SDKNAME parameter.
- The APP business server must respond to this request within the timeout period.
Scenarios That May Trigger This Callback
- App users agree to add someone as a friend after receiving a friend request.
Timing of the Callback
- Triggered after OpenIM Server successfully adds a friend.
Interface Description
Request URL Example
In the following example, the callback URL configured by the App is https://callbackurl
.
https://callbackurl?command=$CallbackCommand&contenttype=json
Request Parameter Description
Parameter | Description |
---|---|
https | Request protocol is HTTPS, method is POST |
https://callbackurl | Callback URL |
CallbackCommand | Fixed value: callbackAfterAddFriendCommand |
contenttype | Fixed value: JSON |
Header
Header Name | Example Value | Mandatory | Type | Description |
---|---|---|---|---|
operationID | 1646445464564 | Required | string | operationID for global link tracing |
Request Packet Example
{
"callbackCommand": "callbackAfterAddFriendCommand",
"fromUserID": "user123",
"toUserID": "user456",
"reqMsg": "Let's be friends!"
}
Request Packet Field Explanation
Field | Type | Description |
---|---|---|
callbackCommand | string | Callback command, here for after agreeing to add a friend |
fromUserID | string | User ID of the person initiating the friend request |
toUserID | string | User ID of the person receiving the friend request |
reqMsg | string | Additional message sent with the friend request |
Response Packet Example
Processing Result
Result of processing the user's request to agree to add a friend.
{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": ""
}
Response Packet Field Explanation
Field | Value | Description |
---|---|---|
actionCode | 0 | Indicates if the business system's callback was executed correctly. 0 means the operation was successful. |
errCode | 20001 | Custom error code, ranging between 20001-29999. Set when actionCode is not 0; set when nextCode is not 1. |
errMsg | "An error message" | Simple error message corresponding to the custom error code. |
errDlt | "Detailed error information" | Detailed error information corresponding to the custom error code. |