YunShang API

SMS Verification Code

Sends a verification code through the Alibaba Cloud SMS service. You may pass a custom code, or leave it blank and let the platform generate a random 6-digit one. Billed per package, 1 deduction per call.

API info

ItemValue
EndpointPOST /api/v3/dxyzm
BillingPackage

Request parameters

ParameterTypeRequiredDescription
phonestringYesRecipient phone number (11 digits)
codestringNoCustom 6-digit code; generated by the platform if omitted

Request example

PHP

<?php
$app_id = 'YOUR_APP_ID';
$app_key = 'YOUR_APP_KEY';
$url = 'https://yunsapi.com/api/v3/dxyzm';
$params = ['phone' => '13800138000'];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-APP-ID: ' . $app_id,
    'X-APP-KEY: ' . $app_key,
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($ch);
curl_close($ch);

echo $resp;

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class SmsDemo {
    public static void main(String[] args) throws Exception {
        String appId = "YOUR_APP_ID";
        String appKey = "YOUR_APP_KEY";
        String url = "https://yunsapi.com/api/v3/dxyzm";
        String body = "{\"phone\":\"13800138000\"}";

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest req = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Content-Type", "application/json")
                .header("X-APP-ID", appId)
                .header("X-APP-KEY", appKey)
                .POST(HttpRequest.BodyPublishers.ofString(body))
                .build();

        HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandlers.ofString());
        System.out.println(resp.body());
    }
}

Response example

{
    "code": 0,
    "msg": "sent successfully",
    "data": {
        "phone": "13800138000",
        "code": "123456",
        "generated": false,
        "remain": 9
    },
    "request_id": "req_xxx"
}

Response parameters

ParameterTypeDescription
data.phonestringRecipient phone number
data.codestringThe code sent this time; compare it with the code you generated locally
data.generatedbooleantrue if generated by the platform, false if a custom code was used
data.remainintegerRemaining quota in the package