All Products
Search
Document Center

ApsaraVideo Live:CreateLiveMessageApp

Last Updated:Aug 12, 2024

Creates an interactive messaging application.

Usage notes

  • When you call other operations to manage an interactive messaging application, you must specify the same data center in which the application is created.
  • An Alibaba Cloud account can create up to 300 interactive messaging applications.

QPS limit

You can call this operation up to 50 times per second per account. Requests that exceed this limit are dropped and you may experience service interruptions. We recommend that you take note of this limit when you call this operation. For more information, see QPS limits.

Debugging

OpenAPI Explorer automatically generates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action String Yes CreateLiveMessageApp

The operation that you want to perform. Set the value to CreateLiveMessageApp.

AppName String No testApp

The name of the application. The name must be 2 to 16 characters in length.

AuditType Integer No 2

The content moderation method. Valid values:

  • 0 (default): disables content moderation.
  • 1: uses built-in content moderation.
  • 2: uses custom content moderation.
AuditUrl String No http://demo.aliyundoc.com/exampleaudit

The URL for content moderation. If you set AuditType to 2, you must specify this parameter. The URL must start with http:// or https:// and cannot contain a private IP address or a port number. For more information about custom content moderation, see the "Custom content moderation" section of this topic.

EventCallbackUrl String No http://demo.aliyundoc.com/examplecallback

The callback URL for events, such as logon, logoff, and joining and leaving a group. If you leave this parameter empty, event callbacks are disabled. The callback URL must start with http:// or https:// and cannot contain a private IP address or a port number. For information about the callback message format and authentication logic, see the "Event callbacks" and "Callback authentication" sections of this topic.

DataCenter String No cn-shanghai

The data center. Valid values:

  • cn-shanghai (default): the data center in the China (Shanghai) region.
  • ap-southeast-1: the data center in the Singapore region.
Note When you call other operations to manage an interactive messaging application, you must specify the same data center in which the application is created.
MsgLifeCycle Integer No 1

The retention period of group messages in the application. Valid values:

  • 0 (default): 30 days.
  • 1: 90 days.
  • 2: 180 days.

Custom content moderation

  • Request protocol: HTTP
  • Request method: POST
  • Sample request:
    {
      "content": "testaudit"
    }
  • Sample response:
    {
      "pass": true,"reason":"****"    | If the value of the pass field is true, the content passed the review. If the value of the pass field is false, the content failed the review. The reason field provides the reason for the failure.
    }
Note The HTTP status code 200 indicates a successful request. If an HTTP status code other than 200 is returned, the service is considered unavailable, and the system does not review the content again.

Event callbacks

The HTTP or HTTPS request method is POST. The request body is a JSON string encoded in UTF-8. Sample event callback:

{
 "transactionid":"A8C7B033-B339-1A58-B0E0-7B9197BA****",
 "appid":"demo",
 "eves":[{
 "uid":"uid1",
 "sid":"sessionid",
 "events":[{
     "e": 3, | The event. Valid values: 1 (logon), 2 (logoff), 3 (joining a group), 4 (leaving a group), and 5 (network reconnection).
     "r": 1, | The reason for logoff. This field is required only for the logoff event. Valid values: 1 (normal call), 3 (timeout), and 4 (logon on another device).
     "g": "testgroup", | The group ID. This field is required only for the event of joining or leaving a group.
     "gs":["testgroupid"] | The IDs of the groups that the client joins. This field is required only for the event of network reconnection.
 }]
 }]
}
Note The HTTP status code 200 indicates a successful request. If an HTTP status code other than 200 is returned, the system resends the request.

Callback authentication

The HTTP or HTTPS request header contains the Ali-Live-Timestamp and Ali-Live-Signature fields for signature verification on the receiving server. The value of the Ali-Live-Signature field is calculated based on the following formula: Ali-Live-Signature = sha256(CONTENT), in which CONTENT = Callback domain name|Ali-Live-Timestamp value|Authentication key. The callback domain name is the domain name of the callback URL. The authentication key is the AppKey generated when you create the application.

Response parameters

Parameter

Type

Example

Description

RequestId String 65EEDBEB-43FE-1E15-976F-3DDD753A****

The request ID.

AppId String demo

The application ID. The ID is used in subsequent operations, such as joining a group.

AppKey String **********************************

The AppKey for authentication of this application.

AppSign String **************************************************************************

The application signature. The signature is required when you use the interactive messaging SDK.

DataCenter String cn-shanghai

The data center in which the interactive messaging application was created.

Example

Sample request

http(s)://live.aliyuncs.com?Action=CreateLiveMessageApp
&AppName=testApp
&AuditType=2
&AuditUrl=http://demo.aliyundoc.com/exampleaudit
&EventCallbackUrl=http://demo.aliyundoc.com/examplecallback
&DataCenter=cn-shanghai
&MsgLifeCycle=1
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateLiveMessageAppResponse>
    <RequestId>65EEDBEB-43FE-1E15-976F-3DDD753A****</RequestId>
    <AppId>demo</AppId>
    <AppKey>**********************************</AppKey>
    <AppSign>**************************************************************************</AppSign>
</CreateLiveMessageAppResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "65EEDBEB-43FE-1E15-976F-3DDD753A****",
  "AppId" : "demo",
  "AppKey" : "**********************************",
  "AppSign" : "**************************************************************************"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InputInvalid %s. The specified parameters are invalid.
400 ErrorInvalidAppName %s. The AppName parameter is invalid.
400 ErrorTooManyApps %s. The number of interactive messaging applications exceeds the limit. An Alibaba Cloud account can create up to 300 interactive messaging applications.
400 ErrorInvalidEventCallbackUrl %s. The EventCallbackUrl parameter is invalid.
400 ErrorInvalidAuditUrl %s. The AuditUrl parameter is invalid.
403 NoAuth %s. You do not have the required permissions.
404 ResourceNotExist %s. The requested resource does not exist.
500 ServerError %s. An unknown error occurred. Try again later or submit a ticket.

For a list of error codes, see Service error codes.