产品详情
API参数 通知短信发送 调用地址: http,https://noticesms.api.bdymkt.com/smsApi/custom 请求方式: POST 支持格式: application/json;charset=UTF-8 调用工具: 去调试 请求参数(Headers) 请求参数(Query)
- 名称
- 类型
- 是否必须
- 示例值
- 描述
- smsId
- string
- true
- 487
- 定制短信模板id。 (请联系客服申请模板,获取模板ID)
- content
- string
- true
- [{"手机号码":"15831471961","姓名":"张三","工资":"10000.00"},{"手机号码":"13076523432","姓名":"李四","工资":"20000.00"}]
- 号码及变量值。 (content字符串由手机号和变量值组成,手机号码为固定key,用于存储用户手机号;其余的key名称需要和平台个性化模板中的变量名称一一对应)。如模板为:【中昱维信】尊敬的${姓名}你好,您本月实发薪资为:${工资},请注意查收! 则提交content为: [{"手机号码":"15831471961","姓名":"张三","工资":"10000.00"},{"手机号码":"13076523432","姓名":"李四","工资":"20000.00"}]
- sendTime
- string
- false
- null
- 定时时间。留空则表示立即发送,时间格式为:yyyy-MM-dd HH:mm:ss
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>api-explorer-sdk</artifactId>
<version>1.0.0</version>
</dependency>
import com.baidubce.http.ApiExplorerClient;
import com.baidubce.http.AppSigner;
import com.baidubce.http.HttpMethodName;
import com.baidubce.model.ApiExplorerRequest;
import com.baidubce.model.ApiExplorerResponse;
// 通知短信发送 Java示例代码
public class RequestDemo {
public static void main(String[] args) {
String path = "http://gwgp-ohrdz9ppwna.n.bdcloudapi.com/smsApi/custom";
ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path);
request.setCredentials("您的 access key", "您的 secret key");
request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8");
request.addQueryParameter("smsId", "");
request.addQueryParameter("content", "");
request.addQueryParameter("sendTime", "");
ApiExplorerClient client = new ApiExplorerClient(new AppSigner());
try {
ApiExplorerResponse response = client.sendRequest(request);
// 返回结果格式为Json字符串
System.out.println(response.getResult());
} catch (Exception e) {
e.printStackTrace();
}
}
}
点击复制代码
正常返回示例 {
"returnStatus": "1 ", //状态码
"message": "成功", //状态提示信息
"remainPoint": "241", //本次发送后,账户剩余条数
"taskId": "3313746", //下发批次ID(唯一)
"successCounts": "1" //成功条数
}
失败返回示例 {
"returnStatus": "0", //状态码
"message": "参数错误", //状态提示信息
"remainPoint": null, //本次发送后,账户剩余条数
"taskId": null, //下发批次ID(唯一)
"successCounts": null //成功条数
}
错误码定义
