目录

Image Risk Control

To ensure network security, Push Kit disabled the TLS 1.0 and TLS 1.1 protocols and unsupported cipher suites for push-related domains on November 30, 2022. After the date, your app is unable to send push messages using the TLS protocol earlier than version 1.2 or unspecified cipher suites.

If your app uses TLS 1.0 or TLS 1.1 to access push-related domains, ensure that the protocol is updated to TLS 1.2 or later.

Function

This API is used to check for risks of an image that is to be sent.

Restrictions

Each app can make a maximum of 60 API calls per minute.

This API is used only for pushing messages. Do not modify images that have passed the image risk check, as this may prevent notification messages from being displayed properly.

Prototype

Protocol

HTTPS POST

Direction

Your server -> Push Kit server

URL

https://push-api.cloud.huawei.com/v1/[clientId]/images:verify

URL

https://push-api.cloud.huawei.com/v2/[projectId]/images:verify

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

  • In the URL, [clientId] indicates the OAuth 2.0 client ID (credential). To obtain the client ID, sign in to AppGallery Connect, click My projects, click the desired project, and go to the Project settings page.
  • In the URL, [projectId] indicates the project ID. To obtain the project ID, sign in to AppGallery Connect, click My projects, click the desired project, and go to the Project settings page.
  • The two URLs point to the same API, but only differ in the authentication mode. You can use either of them.

Request Parameters

Request Header

Parameter

Description

Example

Authorization

Authentication mode:

JWT

For details, please refer to Generating a JWT Based on a Service Account.

NOTE:

You are advised to set the JWT validity period to 3600 seconds, within which a JWT can be reused. The value of this parameter is Bearer followed by a space character and then the obtained authentication information.

Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx

push-type

Message type. The options are as follows:

0: sends a notification containing a large icon

1: updates the image on a service widget

2: sends an extended notification containing a large icon

1

Request Body

Parameter

Mandatory

Type

Description

imageUrl

Yes

String

Public URL of an image to be verified. The protocol must be HTTPS.

Request Example

{
    "imageUrl": "https://example.com/image.png"
}

Response Parameters

Response Body

Parameter

Mandatory

Type

Description

code

Yes

String

Response code.

msg

Yes

String

Response message.

requestId

No

String

Request ID.

downloadUrl

No

String

URL of the image that passes the risk check. (This parameter is returned only when the API call is successful.)

expireTime

No

String

Expiration time of the image risk check, which is a Unix timestamp in seconds. (This parameter is returned only when the API call is successful.)

Response Examples

Success response example:

{
    "code": "83010000",
    "msg": "Verify success",
    "requestId": "1631***********0101",
    "downloadUrl": "https://**.png?verifyKey=MEUCIQDzfYMReU*****************fdCOX9KToGq7o%3D",
    "expireTime": "1689911616"
}

Failure response example:

{
    "code": "83010005",
    "msg": "Download picture failed",
    "requestId": "1691***********1501"
}

Response Codes

HTTP Response Code

Description

Solution

400

Invalid parameter.

Check the service response code and locate the fault accordingly.

401

Authentication failed.

Verify the JSON Web Token (JWT) in the Authorization parameter in the HTTP request header.

404

Service not found.

Verify that the request URI is correct.

500

Internal service error.

Submit a ticket online for assistance.

502

The connection request is abnormal, generally because the network is unstable.

Try again later or submit a ticket online.

Service Response Code

Description

Solution

80100001

Invalid parameter.

Verify the request parameters as prompted in the response.

80100003

Invalid URL format.

The value of imageUrl must use the HTTPS protocol.

80200001

OAuth authentication error.

The JWT in the Authorization parameter in the HTTP request header failed to be authenticated. Ensure that the JWT is correct.

80200003

OAuth token expired.

The JWT in the Authorization parameter in the HTTP request header has expired. Obtain a new JWT.

80200005

The JWT expired.

The JWT in the Authorization parameter has expired. Generate a new JWT and try again.

80300002

No permission.

Verify that Push Kit has been enabled for the project.

83010000

The image passes the risk check.

N/A

83010001

The image failed the risk check.

Verify that the image does not contain sensitive information.

83010002

The request frequency exceeds the traffic control threshold.

Decrease the request frequency and try again.

83010003

Empty message body.

Verify that the message body content is correct.

83010004

Risk check is not supported.

No risk control policy is matched. Submit a ticket online for assistance.

83010005

Image download failed.

Verify that the image URL in the request body is correct.

83010007

Incorrect message type.

Verify that push-type is correctly set.