Invoke a Callback After Modifying Group Profiles

Last updated: 2020-03-24 16:41:10

PDF

Feature Description

The app backend uses this callback to monitor changes to group information (including the group name, group introduction, group notification, profile photo, and group-specific custom fields) in real time, including recording the changes of group information in real time (for example, recording a log or synchronizing the changes to other systems).

Precautions

  • To enable this callback, you must configure the callback URL and toggle on the corresponding protocol. For details on the configuration method, see Third-Party Callback Configuration.
  • Callback direction: the IM backend initiates an HTTP POST request to the app backend.
  • After receiving the callback request, the app backend must check whether the SDKAppID contained in the request URL is consistent with its own SDKAppID.
  • For other security-related issues, see Third-Party Callback Overview: Security Considerations.

Callback Triggering Scenarios

Content that may trigger the callback

Group information includes basic group information and group-specific custom fields.
Currently, this callback may be triggered when the group name, group introduction, group notification, or profile photo URL is modified. This callback is not triggered when other basic group information is modified.

Callback triggering scenarios

  • An app user modifies group information through a client.
  • The app admin modifies group information through a RESTful API.

Callback Triggering Time

The callback is triggered after basic group information is modified.

API Description

Request URL example

In the following example, the callback URL configured in the app is https://www.example.com.
Example:

https://www.example.com?SdkAppid=$SDKAppID&CallbackCommand=$CallbackCommand&contenttype=json&ClientIP=$ClientIP&OptPlatform=$OptPlatform

Request parameters

Parameter Description
https The request protocol is HTTPS, and the request method is POST.
www.example.com The callback URL.
SdkAppid The SDKAppID assigned by the IM console when an app is created.
CallbackCommand The value is fixed to Group.CallbackAfterGroupInfoChanged.
contenttype The value is fixed to JSON.
ClientIP The client IP address, whose format is similar to 127.0.0.1.
OptPlatform The client platform. For details on the possible values, see the OptPlatform parameter in Third-Party Callback Overview: Callback Protocols.

Request packet examples

Modifying part of basic group information

If part of basic group information is modified, the request packet contains only the basic group information fields that have been modified.

{
    "CallbackCommand": "Group.CallbackAfterGroupInfoChanged", // Callback command
    "GroupId" : "@TGS#2J4SZEAEL",
    "Type": "Public", // Group type
    "Operator_Account": "leckie", // Operator
    "Notification": "NewNotification" // Modified group announcement
}

Modifying part of group-specific custom fields

If part of group-specific custom fields are modified, the request packet contains only the group-specific custom fields that have been modified.

{
    "CallbackCommand": "Group.CallbackAfterGroupInfoChanged", // Callback command
    "GroupId" : "@TGS#2J4SZEAEL",
    "Type": "Public", // Group type
    "Operator_Account": "leckie", // Operator
    "UserDefinedDataList": [ // Modified group-specific custom fields
        {
            "Key": "UserDefinedKey2", // Key of the custom field
            "Value": "UserDefinedValue2" // Value of the custom field
        }
    ]
}

Modifying both basic group information and group-specific custom fields

{
    "CallbackCommand": "Group.CallbackAfterGroupInfoChanged", // Callback command
    "GroupId" : "@TGS#2J4SZEAEL",
    "Type": "Public", // Group type
    "Operator_Account": "leckie", // Operator
    "Name": "NewGroupName", // Changed group name
    "Introduction": "NewIntroduction", // Modified group introduction
    "Notification": "NewNotification", // Modified group announcement
    "FaceUrl": "NewFaceUrl", // Changed group profile photo URL
    "UserDefinedDataList": [ // Modified group-specific custom fields
        {
            "Key": "UserDefinedKey1", // Key of the custom field
            "Value": "UserDefinedValue1" // Value of the custom field
        },
        {
            "Key": "UserDefinedKey2",
            "Value": "UserDefinedValue2"
        },
        {
            "Key": "UserDefinedKey3",
            "Value": "UserDefinedValue3"
        }
    ]
}

Request packet fields

Field Type Description
CallbackCommand String The callback command.
GroupId String The ID of the group whose information is modified.
Type String The type of the group whose information is modified, such as Private, Public, or ChatRoom. For details, see Group Types.
Operator_Account String The UserID of the operator.
Name String The changed group name.
Introduction String The modified group introduction.
Notification String The modified group announcement.
FaceUrl String The changed group profile photo URL.
UserDefinedDataList Array The modified group-specific custom fields.

Response packet example

After recording group information changes, the app backend sends a callback response packet.

{
    "ActionStatus": "OK",
    "ErrorInfo": "",
    "ErrorCode": 0 // Ignore the result in the response
}

Response packet fields

Field Type Attribute Description
ActionStatus String Required The request processing result. OK: succeeded. FAIL: failed.
ErrorCode Integer Required The error code. The 0 value indicates that the result in the response is ignored.
ErrorInfo String Required Error information.

References