tencent cloud

Feedback

Service Callbacks

Last updated: 2023-09-05 18:14:00

    Overview

    Note:
    LCIC can send you callbacks to notify you of different events in your business. They allow you to collect statistics before, during, and after classes.
    
    
    
    
    
    1. Configure a callback URL: Go to the LCIC console and select Application Management on the left sidebar. Click Settings, and configure a callback URL in the Configure callbacks area.
    
    
    
    
    
    
    2. You can use the GetRoomEvent API to obtain the events of a room. This API must be called within one hour of the end of a class. After one hour, the room events will be cleared.
    3. Room event list
    Event Type
    Event Name
    Description
    Room events
    RoomStart
    The room started.
    RoomEnd
    The room ended.
    The room expired.
    Recording events
    The recording ended.
    Member events
    A user joined the room.
    A user left the room.
    Document events
    The transcoding of a document is finished.
    A document was created.
    A document was deleted.

    Calculating the Callback Signature

    Note:
    Callback authentication is not required. However, for security reasons, we recommend you authenticate callbacks on your business server.
    LCIC provides a callback key to authenticate callback messages. Below is the signature algorithm:
    Sign = md5(CallbackKey+ExpireTime)
    
    Example:
    CallbackKey = NjFGoDEy
    ExpireTime = 1614151508
    Sign = md5(NjFGoDEy1614151508) = b9454ab5a85f9b7ad36071f5688ed34d
    ExpireTime is the signature expiration time. If the time specified by ExpireTime in a message notification has elapsed, the notification can be considered invalid. This can prevent network replay attacks. The format of this parameter is a decimal Unix timestamp, i.e., the number of seconds that have elapsed since 00:00 (UTC/GMT time) on January 1, 1970.
    Go
    Java
    Python3
    package main
    
    import(
        "crypto/md5"
        "fmt"
    )
    
    func main(){
        callbackKey := "NjFGoDEy"
        expire := 1614151508
        sign := fmt.Sprintf("%x", md5.Sum([]byte(callbackKey+fmt.Sprintf("%d", expire))))
        fmt.Printf(fmt.Sprintf("sign:%s", sign)) // sign:b9454ab5a85f9b7ad36071f5688ed34d
    }
    String md5Str = DigestUtils.md5DigestAsHex("NjFGoDEy1614151508".getBytes());
    # Python 3 code to demonstrate the
    # working of MD5 (string - hexadecimal)
     
    import hashlib
     
    # initializing string
    str2hash = "NjFGoDEy1614151508"
    result = hashlib.md5(str2hash.encode())
     
    # printing the equivalent hexadecimal value.
    print("sign:", end ="")
    print(result.hexdigest()) #sign:b9454ab5a85f9b7ad36071f5688ed34d
    The callback request you receive will include the ExpireTime parameter and the Sign parameter, which you can use together with the callback key to determine whether the request is legitimate.

    Callback Protocol

    We will send an HTTP POST request to the callback URL you configured. The request body is in JSON format:
    Parameter
    Type
    Description
    Timestamp
    Integer
    The Unix timestamp (seconds) when the event occurred.
    ExpireTime
    Integer
    The Unix timestamp (seconds) when the signature expires. If the current time is later than the expiration time, the request can be considered invalid.
    Sign
    String
    The callback signature. You can use the method described above to determine whether the signature is correct and consequently whether the request is legitimate.
    SdkAppId
    Integer
    The application the event belongs to.
    EventType
    String
    See the descriptions of different callback types.
    EventData
    JSON
    See the descriptions of different callback types.
    Callback request example
    Callback response example
    POST xxxxxxxxxxxxxxx(user-callback-url)
    Content-Type: application/json; charset=utf-8
    Accept: application/json
    
    {
    "Timestamp":1679279232,
    "ExpireTime":1679279832,
    "Sign":"fbfd23733e6262f49e402247024fbc29", // See "Calculating the Callback Signature".
    "SdkAppId":3520371,
    "EventType":"RoomStart",
    "EventData":{
    "RoomId":366317280
    }
    }
    Response: HTTP STATUS CODE = 200. You need to add `JSON: {"error_code":0}` to the response.
    
    
    HTTP STATUS CODE 200 OK
    
    HTTP BODY:
    {
    "error_code":0
    }

    Event List

    Room start event

    Event type
    RoomStart
    Description
    This callback is sent when a room starts.
    Fields
    Field
    Type
    Description
    RoomId
    Integer
    The room ID.
    Example
    {
    "Timestamp":1679279232,
    "ExpireTime":1679279832,
    "Sign":"fbfd23733e6262f49e402247024fbc29",
    "SdkAppId":3520371,
    "EventType":"RoomStart",
    "EventData":{
    "RoomId":366317280
    }
    }

    Room end event

    Event type
    RoomEnd
    Description
    This callback is sent when a room ends.
    Fields
    Field
    Type
    Description
    RoomId
    Integer
    The room ID.
    Example
    {
    "Timestamp":1679279195,
    "ExpireTime":1679279795,
    "Sign":"696560af8fec9374b4cd58c6318c6448",
    "SdkAppId":3520371,
    "EventType":"RoomEnd",
    "EventData":{
    "RoomId":311601250
    }
    }

    Room expiration event

    Event type
    RoomExpire
    Description
    This callback is sent when a room expires.
    Fields
    Field
    Type
    Description
    RoomId
    Integer
    The room ID.
    Example
    {
    "Timestamp":1679282220,
    "ExpireTime":1679282820,
    "Sign":"07e504e36a3738cf17a47f47b37c0d3c",
    "SdkAppId":3520371,
    "EventType":"RoomExpire",
    "EventData":{
    "RoomId":310096990
    }
    }

    Recording completion event

    Event type
    RecordFinish
    Description
    This callback is sent when the system finishes recording a class and generates a playback URL.
    Fields
    Field
    Type
    Description
    RoomId
    Integer
    The room ID.
    Duration
    Integer
    The recording duration (seconds).
    RecordUrl
    String
    The recording URL (HTTPS).
    RecordSize
    Integer
    The recording file size (bits).
    Example
    {
    "Timestamp":1679279203,
    "ExpireTime":1679279803,
    "Sign":"7ada1f46f27ce6f1cdeb22339d71e094",
    "SdkAppId":3520371,
    "EventType":"RecordFinish",
    "EventData":{
    "Duration":63,
    "RecordSize":698472,
    "RecordUrl":"https://xxxxxxx.vod2.myqcloud.com/xxxx/xxxxxxx/f0.mp4",
    "RoomId":311601250
    }
    }

    Member entry event

    Event type
    MemberJoin
    Description
    This callback is sent when a user enters the room.
    Fields
    Field
    Type
    Description
    RoomId
    Integer
    The room ID.
    UserId
    String
    The user ID.
    Example
    {
    "Timestamp":1679279225,
    "ExpireTime":1679279825,
    "Sign":"6fcaf48026fe95d76d1615c44ea98ede",
    "SdkAppId":3520371,
    "EventType":"MemberJoin",
    "EventData":{
    "RoomId":366317280,
    "UserId":"2Lzh8d3Rw7zOlpEnNgHPe6HDiDn"
    }
    }

    Member exit event

    Event type
    MemberQuit
    Description
    This callback is sent when a user leaves the room.
    Fields
    Field
    Type
    Description
    RoomId
    Integer
    The room ID.
    UserId
    String
    The user ID.
    Example
    {
    "Timestamp":1679279260,
    "ExpireTime":1679279860,
    "Sign":"03d41254d4ba7a05e13299a4841c3d99",
    "SdkAppId":3520371,
    "EventType":"MemberQuit",
    "EventData":{
    "RoomId":397322814,
    "UserId":"2NG5xjpnYLGo3bq1taJbItY1TPf"
    }
    }

    Document transcoding completion event

    Event type
    DocumentTranscodeFinish
    Description
    This callback is sent when the transcoding of a courseware file is completed (succeeds or fails).
    Fields
    Field
    Type
    Description
    DocumentId
    String
    The document ID.
    State
    Integer
    The document status.
    Result
    String
    The transcoding result. If the transcoding succeeded, this parameter is the URL of the transcoding output; if the transcoding failed, this parameter is the error code.
    Info
    String
    The transcoding information.
    Thumbnail
    String
    The thumbnail URL. A PowerPoint file usually has multiple thumbnails. The URL of the first thumbnail is thumbnail_url/1.jpg.
    Example
    {
    "Timestamp":1679281156,
    "ExpireTime":1679281756,
    "Sign":"1597c5c8aaafb623ece9d1690dc0e780",
    "SdkAppId":3520371,
    "EventType":"DocumentTranscodeFinish",
    "EventData":{
    "DocumentId":"sixkzoak",
    "Info":"",
    "Result":"https://xxx.cos.ap-shanghai.myqcloud.com/doc/xxxxxx/picture/",
    "State":3,
    "Thumbnail":"https://xxxxx.cos.ap-shanghai.myqcloud.com/doc/xxxxx/thumbnail/"
    }
    }

    Document creation event

    Event type
    DocumentCreate
    Description
    This callback is sent when a document is successfully created.
    Fields
    Field
    Type
    Description
    DocId
    String
    The document ID.
    DocName
    String
    The document name.
    Owner
    String
    The user ID of the document's owner.
    DocSize
    Integer
    The file size (bytes).
    DocUrl
    String
    The document URL.
    Permission
    Integer
    The document access: 0: Private; 1: Public.
    Example
    {
    "Timestamp":1679281150,
    "ExpireTime":1679281750,
    "Sign":"44f0a2e422ede67100a1f419df3ef51c",
    "SdkAppId":3520371,
    "EventType":"DocumentCreate",
    "EventData":{
    "DocId":"sixkzoak",
    "DocName":"test.pdf",
    "DocSize":4162606,
    "DocUrl":"https://xxxx.cos.ap-shanghai.myqcloud.com/uploads/xxxxx/xxxxxx/xxxxxx.pdf",
    "Owner":"2Lzh8d3Rw7zOlpEnNgHPe6HDiDn",
    "Permission":0
    }
    }

    Document deletion event

    Event type
    DocumentDelete
    Description
    This callback is sent when a document is successfully deleted.
    Fields
    Field
    Type
    Description
    DocId
    String
    The document ID.
    Example
    {
    "Timestamp":1679281184,
    "ExpireTime":1679281784,
    "Sign":"964ff6d9463280d6a3bd4f7416213be9",
    "SdkAppId":3520371,
    "EventType":"DocumentDelete",
    "EventData":{
    "DocId":"sixkzoak"
    }
    }

    Custom event

    Event type
    TaskUpdate
    Description
    This callback is sent when JSAPI updateTask is called in the custom UI with the parameter enableCallback = true.
    Fields
    Field
    Type
    Description
    RoomId
    String
    The room ID.
    TaskId
    String
    task ID(taskId in updateTask,which can be modified)
    CustomData
    String
    CustomData( content in updateTask)
    Example
    JS Example Code
    {
    "Timestamp": 1679281184,
    "ExpireTime": 1679281784,
    "Sign": "964ff6d9463280d6a3bd4f7416213be9",
    "SdkAppId": 3520371,
    "EventType": "TaskUpdate",
    "EventData": {
    "RoomId": "397322814",
    "TaskId": "your-task-id",
    "CustomData": "{\\"key1\\":\\"value1\\",\\"key2\\":\\"value2\\"}"
    }
    }
    TCIC.SDK.instance.updateTask(
      'your-task-id', // taskId
      JSON.stringify({ key1: 'value1', key2: 'value2' }), // content
      -1, // duration
      false, // createOnly
      '', // bindingUser
      true, // enableCallback
    );
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support