{"api": "enableAutoSnapshotAndUpload","params" : {"'enable": 1, //Start/stop automatic screenshot, int, required. Field values: 0: stop, and 1: start. The passed value shall not be empty, and bool values (true and false) are supported."intervalS": 1, //Screenshot interval, int, optional. The interval is expressed in second, with the default value of 3 seconds and the minimum interval of 1 second. The passed value for the field shall not be empty. If it is less than 1, the minimum value of 1 second will be taken."streamType": 0, //Stream type, int, optional. Field values: 0: BigStream, and 2: SubStream. The passed value shall not be empty. Default behavior: If this field is not passed when starting a screenshot, the starting will not take effect. If this field is not passed, all tasks will stop when a screenshot is stopped."extraInfo": "customized messages" //Screenshot upload additional information, string, optional. This information will be sent to your business backend through a server-side callback.}}
Field name | Value |
Content-Type | application/json |
Sign | Signature value |
SdkAppId | sdk application id |
Field name | Type | Meaning |
EventGroupId | Number | Event group ID, the value of a screenshot event (EVENT_GROUP_SCREEN_SHOT) is 6 |
EventType | Number | The event type of the callback notification, the value of a video screenshot (EVENT_TYPE_VIDEO_SCREENSHOT) is 601 |
CallbackTs | Number | The Unix timestamp when the event callback server sends a callback request to your server, expressed in millisecond |
EventInfo | JSON Object | Event information |
Field name | Type | Meaning |
eventId | String | The event ID for this callback |
callbackData | String | Screenshot upload additional information, reported via the client's extraInfo |
pictureURL | String | The URL of the screenshot |
code | Number | Task execution status code, default: 0, indicating that the task is executed successfully |
msg | String | Description information of task execution |
roomID | String/Number | Room ID |
streamType | String | Stream type of the screenshot, BigStream or SubStream |
userID | String | Screenshot username |
timestamp | Number | UTC timestamp of the screenshot, accurate to millisecond |
{"EventGroupId": 6,"EventType": 601,"CallbackTs": 1698410059705,"EventInfo": {"eventID": "ap-guangzhou-1400000000-1698410059243691647-60022-jpg.jpg","callbackData": "test","pictureURL": "https://sotest-1200000000.cos.ap-guangzhou.myqcloud.com/1400000000/ap-guangzhou-1400000000-1698410059243691647-60022-jpg.jpg","code": 0,"msg": "","roomID": "464884","streamType": "BigStream","userID": "dd","timestamp": 1698410059693}}
//In the calculation formula of Sign, the key is the encryption key for calculating the Sign.Sign = base64 (hmacsha256(key, body))
body="{\\n\\t\\"EventGroupId\\":\\t1,\\n\\t\\"EventType\\":\\t103,\\n\\t\\"CallbackTs\\":\\t1615554923704,\\n\\t\\"EventInfo\\":\\t{\\n\\t\\t\\"RoomId\\":\\t12345,\\n\\t\\t\\"EventTs\\":\\t1608441737,\\n\\t\\t\\"UserId\\":\\t\\"test\\",\\n\\t\\t\\"UniqueId\\":\\t1615554922656,\\n\\t\\t\\"Role\\":\\t20,\\n\\t\\t\\"Reason\\":\\t1\\n\\t}\\n}"
import javax.crypto.Mac;import javax.crypto.spec.SecretKeySpec;import java.util.Base64;//# Feature: Verification of the third-party callback sign//# Parameters://# Key: The key configured in the console//# Body: The body returned by Tencent Cloud callback//# Sign: The sign returned by Tencent Cloud callback//# Returned values://# Status OK indicates that it has passed the verification, and FAIL indicates that it has failed the verification. For specific reasons, see Info//# Info: The information of pass/failpublic class checkSign {public static String getResultSign(String key, String body) throwsException {Mac hmacSha256 = Mac.getInstance("HmacSHA256");SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(),"HmacSHA256");hmacSha256.initialize(secret_key);returnBase64.getEncoder().encodeToString(hmacSha256.doFinal(body.getBytes()));}public static void main(String[] args) throws Exception {String key = "123654";String body = "{\\n" + "\\t\\"EventGroupId\\":\\t2,\\n" +"\\t\\"EventType\\":\\t204,\\n" + "\\t\\"CallbackTs\\":\\t1664209748188,\\n" +"\\t\\"EventInfo\\":\\t{\\n" + "\\t\\t\\"RoomId\\":\\t8489,\\n" +"\\t\\t\\"EventTs\\":\\t1664209748,\\n" + "\\t\\t\\"EventMsTs\\":\\t1664209748180,\\n" +"\\t\\t\\"UserId\\":\\t\\"user_85034614\\",\\n" + "\\t\\t\\"Reason\\":\\t0\\n" + "\\t}\\n" +"}";String Sign = "kkoFeO3Oh2ZHnjtg8tEAQhtXK16/KI05W3BQff8IvGA=";String resultSign = obtainResultSignature(key, body);if (resultSign.equals(Sign)) {System.out.println("{'Status': 'OK', 'Info': 'Verification passed'}");} else {System.out.println("{'Status': 'FAIL', 'Info': 'Verification failed'}");}}}
Was this page helpful?