合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
| 请求类型 | 请求地址 | | --- | --- | | POST | [http://send.6web.cn/api/Check/send](http://send.6web.cn/api/Check/send) | | 参数名 | 类型 | 描述 | | --- | --- | --- | | domain | String | 网站域名 | | key | String | 密钥 | | phone | String | 发信手机号 | | content | String | 发信内容 | | Extnum | String | 发信标识(四位数 字) | | sendid | String | 发信模板 ID | ~~~ 请求成功 -> 返回码 { "code": "1", "msg": "发送成功", } ~~~ ~~~ 请求失败 -> 返回码 { "code": "0", "msg": "错误信息", } ~~~ ~~~ 参照代码(PHP) ~~~ ~~~ <?php $url =http:// send.6web.cn/api/Check/send'; $phone = '18888888';//手机号 $sendid = '1001';//模板ID $Extnum = mt_rand(1000, 9999);//发信标识 $content= '发送的内容'; $postdata = [ 'domain' =>$_SERVER['HTTP_HOST'], 'key' => '用户密钥', 'phone' =>$phone, 'content' => $content, 'Extnum' => $Extnum, 'sendid' => $sendid ]; $result = request_post($url,$postdata); $status = json_decode($result,true); if($status['code'] != '0'){ //发送失败,参考返回的msg }else{ //发送成功 } function request_post($url = '', $post_data =0) { if (empty($url) || empty($post_data)) { return false; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $httpheader[] = "Accept:*/*"; $httpheader[] = "Accept-Encoding:gzip,deflate,sdch"; $httpheader[] = "Accept-Language:zh-CN,zh;q=0.8"; $httpheader[] = "Connection:close"; curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); if ($post_data) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($ch); curl_close($ch); return $ret; } ~~~ ~~~ 参照代码(JAVA) ~~~ ~~~ import java.util.HashMap; import java.util.Map; public class SmsSender { public static void main(String[] args) { String url = "http://send.6web.cn/api/Check/send"; String phone = "18888888";// 手机号 String sendid = "1001";// 模板ID int extnum = (int) (Math.random() * 9000) + 1000;// 发信标识 String content = "发送的内容"; Map<String, String> postdata = new HashMap<String, String>(); postdata.put("domain", System.getenv("HTTP_HOST")); postdata.put("key", "用户密钥"); postdata.put("phone", phone); postdata.put("content", content); postdata.put("Extnum", Integer.toString(extnum)); postdata.put("sendid", sendid); String result = requestPost(url, postdata); Map<String, Object> statusMap = jsonDecode(result);// 假设已经实现了该方法 String code = (String) statusMap.get("code"); if (!"0".equals(code)) { // 发送失败,参考返回的msg String msg = (String) statusMap.get("msg"); System.out.println("发送失败:" + msg); } else { // 发送成功 System.out.println("发送成功"); } } private static String requestPost(String url, Map<String, String> postdata) { // 实现HTTP POST请求并返回结果的代码 // ... return ""; } private static Map<String, Object> jsonDecode(String json) { // 解析JSON并返回结果的代码 // ... return new HashMap<>(); } } ~~~