|
| 1 | +# Callback Before Updating User Information Ex |
| 2 | + |
| 3 | +## Function Description |
| 4 | +The App business server can use this callback to receive requests from users to update their personal information. Additionally, the business server can modify and intervene in the request. |
| 5 | + |
| 6 | +## Precautions |
| 7 | +- 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](../introduction) document. |
| 8 | +- The direction of the callback is an HTTP/HTTPS POST request initiated by OpenIMServer to the App backend. |
| 9 | +- After receiving the callback request, the App business server must verify whether the command parameter in the request URL is its SDKNAME parameter. |
| 10 | +- The APP business server must respond to this request within the timeout period. |
| 11 | + |
| 12 | +## Scenarios That May Trigger This Callback |
| 13 | +- App users update their personal information through the client. |
| 14 | +- App administrators update user information through the REST API. |
| 15 | + |
| 16 | +## Timing of the Callback |
| 17 | +- Before OpenIMServer prepares to update user information. |
| 18 | + |
| 19 | +## Interface Description |
| 20 | + |
| 21 | +### Request URL Example |
| 22 | +In the following example, the callback URL configured by the App is `https://callbackurl`. |
| 23 | +```plaintext |
| 24 | +https://callbackurl?command=$CallbackCommand&contenttype=json |
| 25 | +``` |
| 26 | + |
| 27 | +### Request Parameter Description |
| 28 | + |
| 29 | +| Parameter | Description | |
| 30 | +|----------------------|------------------------------------------------------| |
| 31 | +| https | Request protocol is HTTPS, method is POST | |
| 32 | +| https://callbackurl | Callback URL | |
| 33 | +| CallbackCommand | Fixed value: callbackBeforeUpdateUserInfoExCommand | |
| 34 | +| contenttype | Fixed value: JSON | |
| 35 | + |
| 36 | +### Header |
| 37 | +| Header Name | Example Value | Mandatory | Type | Description | |
| 38 | +|-------------|---------------|-----------|--------|-------------------------------------| |
| 39 | +| operationID | 1646445464564 | Required | string | operationID for global link tracing | |
| 40 | + |
| 41 | +### Request Packet Example |
| 42 | +```json |
| 43 | +{ |
| 44 | + "callbackCommand": "callbackBeforeUpdateUserInfoExCommand", |
| 45 | + "userID": "user123", |
| 46 | + "nickName": "John Doe", |
| 47 | + "faceURL": "http://example.com/path/to/face/image.png", |
| 48 | + "ex": "Extra data" |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +### Request Packet Field Explanation |
| 53 | + |
| 54 | +| Field | Type | Description | |
| 55 | +|-----------------|---------|-------------------------------------------| |
| 56 | +| callbackCommand | string | Callback command, here for before updating user information | |
| 57 | +| userID | string | The unique identifier of the user | |
| 58 | +| nickName | StringValue | The nickname of the user | |
| 59 | +| faceURL | StringValue | URL of the user's avatar | |
| 60 | +| ex | StringValue | Additional data fields | |
| 61 | + |
| 62 | +## Response Packet Example |
| 63 | + |
| 64 | +### Allow Update |
| 65 | +Allows the user to update their information. |
| 66 | + |
| 67 | +```json |
| 68 | +{ |
| 69 | + "actionCode": 0, |
| 70 | + "errCode": 0, |
| 71 | + "errMsg": "Success", |
| 72 | + "errDlt": "", |
| 73 | + "nextCode": "0", |
| 74 | + "nickName": "John Doe Updated", |
| 75 | + "faceURL": "http://example.com/new/face/image.png", |
| 76 | + "ex": "Updated extra data" |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +## Response Packet Field Explanation |
| 81 | + |
| 82 | +| Field | Value | Description | |
| 83 | +|------------|--------|----------------------------------------------------------| |
| 84 | +| actionCode | 0 | Indicates if the business system's callback was executed correctly. `0` means the operation was successful. | |
| 85 | +| errCode | 5001 | Custom error code, ranging between 5000-9999. Set when actionCode is not 0; set when nextCode is not 1. | |
| 86 | +| errMsg | "An error message" | Simple error message corresponding to the custom error code. | |
| 87 | +| errDlt | "Detailed error information" | Detailed error information corresponding to the custom error code. | |
| 88 | +| nextCode | 1 | Next step instruction, `1` means to refuse to continue executing, set when actionCode is `0`. | |
| 89 | +| nickName | StringValue | The nickname of the user. | |
| 90 | +| faceURL | StringValue | URL of the user's updated avatar. | |
| 91 | +| ex | StringValue | Updated additional data fields. | |
0 commit comments