Webhook before Sending Gift
Feature Description
The App backend can use the callback to determine whether to pass the gift-sending verification in other scenarios.
Precautions
Enable callback Configure callback URL and turn on the switch corresponding to this callback. For the configuration method, see Third-Party Webhook Configuration.
The callback direction is from the Live backend to the App backend via an HTTP POST request.
After receiving a callback request, the App backend needs to verify whether the value of the SDKAppID parameter in the request URL is its own SDKAppID.
Callback Triggering Scenarios
App user sends a gift through the client
Callback Triggering Timing
Before sending a gift.
API Description
Sample Request URL
In the following example, the callback URL configured for 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 | Callback URL. |
SdkAppid | The SDKAppID assigned in the IM console when creating an application. |
CallbackCommand | Fixed as Live.CallbackAfterCreateBattle. |
contenttype | The value is fixed as json. |
ClientIP | Client IP address in the format of 127.0.0.1. |
OptPlatform | Client platform. For the valid values, see the description of the OptPlatform parameter in Webhook Protocol in Webhook Overview. |
Sample Request Packet
{"CallbackCommand": "Live.CallbackBeforeSendGift","Operator_Account": "brennanli","RoomId":"room_id","GiftWater": {"From_Account": "from","To_Account": ["to1"],"Time": 1703589922,"GiftId": "gift1","Count": 1,"Coins": 1000}}
Request Packet Fields
Field | Type | Description |
CallbackCommand | String | callback command. |
Operator_Account | String | Operator UserID who triggered the battle request. |
RoomId | String | room ID. |
From_Account | String | gift sender. |
To_Account | Array | gift recipient. |
Time | Integer | Timestamp. |
GiftId | String | gift ID. |
Count | Integer | gift number. |
Coins | Integer | gift value. |
Sample Response Packet
The callback response packet is sent after the App backend synchronizes the data.
{"ActionStatus": "OK","ErrorInfo": "","ErrorCode": 0}
If the App needs to block gift sending, set the response packet ErrorCode to non-zero. If the live backend does not receive the response packet within 2s, gift sending will also be blocked by default.
If the App needs the gift sending non-blocking scenario (if the response packet fails to reply or the live backend does not return the response packet within the timeout period, it will allow at this point), you can set the pre-gift callback non-blocking configuration.
Response Packet Fields
Field | Type | Attribute | Description |
ActionStatus | String | Required | Request processing result. OK: processing successful; FAIL: processing failed. |
ErrorCode | Integer | Required | Error code. Enter 0 here to ignore the callback result. |
ErrorInfo | String | Required | Error Message. |