SDK guide

更新时间:
复制 MD 格式

Use OpenAPI Explorer to call Direct Mail API operations, debug them, and generate SDK sample code.

Use OpenAPI Explorer to find, debug, and generate sample code for Direct Mail API operations.

Basic process:

1. Go to the OpenAPI Explorer page

Example: send an email.

Send an email (debug and view sample code)

Send a single email:

Debug and view sample code:

https://next.api.aliyun.com/api/Dm/2015-11-23/SingleSendMail

Note

Loop and concurrent calls are supported.

A single request supports up to 100 recipient addresses. Other parameters are described in SingleSendMail.

Send batch emails:

Debug and view sample code:

https://next.api.aliyun.com/api/Dm/2015-11-23/BatchSendMail

Note

Use a template and recipient list created in the console or via API to send batch emails. Other parameters are described in BatchSendMail.

2. Query for API operations and specify parameters

Use the default API version 2015-11-23. The version identifier stays the same while API operations receive ongoing updates.

image

View the API operation documentation:

image

3. Select a programming language to debug

Select a programming language and click "Initiate Call".

image

4. Generate sample code

Method 1: Use the Direct Mail SDK

Get the SDK installation command

After a successful test, install the SDK on your local machine or server.

The "SDK Info" section shows the SDK version and installation command.

image

image

Method 2: Use CommonRequest

Switch to "Generate code in Common mode". Parameters are passed in the request body by default to avoid URL length limits.

image

C# example:

The "Invalid URI: The Uri string is too long" error is reported when you use the C# SDK to send long content

References:

Java generalized calls 1.0 (To be deprecated)

Java generalized calls 2.0

FAQ

How do I create an AccessKey?

When logged in to your Alibaba Cloud account, the debugging page does not require a key. However, you must configure the key in your code for local or server deployment.

You can also use an AccessKey pair created in RAM.

  1. Log on to the AccessKey Management console.

  2. In the upper-right corner, click Create AccessKey.

  3. Read the prompt and click OK.

Warning

Do not hard-code the "accessKeyId" and "accessKeySecret" values in your code to prevent leaks.

Alibaba Cloud SDKs support ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables for authentication, as described in Identity verification configuration.

SignatureDoesNotMatch error

SignatureDoesNotMatch

Message: Specified signature is not matched with our calculation.

1. If you use a self-signing mechanism, check that the parameter order and encoding are correct. Use the Direct Mail SDK to simplify the signing process.

2. Check if the AccessKey secret is incorrect.

Error message for an incorrect AccessKey ID: Specified access key is not found.

Error message for an incorrect AccessKey secret: Specified signature is not matched with our calculation.

3. Check the system time difference.

Verify that your system time does not differ from the server time by more than 15 minutes.

If your system is in a different time zone, synchronize it with UTC+8.

Commands to query the system time

Windows:

echo %date% %time%
tzutil /g

Mac:

date
systemsetup -gettimezone