## 注意事项
>只会获取最新的回复,不可重复获取,如二次获取请联系管理员
>
| 请求类型 | 请求地址 |
| --- | --- |
| POST | http://send.6web.cn/api/Check/searchAll|
| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| domain| String | 网站域名 |
| key| String | 密钥 |
| sendid| String | 发信模板 ID |
```
请求成功 -> 返回码
{
"code": "1",
"msg": "所有回复手机号,内容,发信标识",
}
```
~~~
请求失败 -> 返回码
{
"code": "0",
"msg": "错误信息",
}
~~~
~~~
参照代码(PHP)
~~~
~~~
<?php
$url =http:// send.6web.cn/api/Check/searchAll';
$sendid = '1001';//模板ID
$postdata = [
'domain' =>$_SERVER['HTTP_HOST'],
'key' => '用户密钥',
'sendid' => $sendid
];
$result = request_post($url,$postdata);
$status = json_decode($result,true);
if($status['code'] != '0'){
//获取失败,参考返回的msg
}else{
//获取成功,将回复保存
$data = $status['msg'];//获取回复信息
foreach ($data as $v) {
$v['phone'];//手机号
$v['text'];//回复内容
$v['date'];//手机
$v['Extnum'];//标识
}
}
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/searchAll";
String sendid = "1001";// 模板ID
Map<String, String> postdata = new HashMap<String, String>();
postdata.put("domain", System.getenv("HTTP_HOST"));
postdata.put("key", "用户密钥");
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 {
// 获取成功,将回复保存
Object msgObj = statusMap.get("msg");
if (msgObj instanceof Object[]) {
Object[] msgArr = (Object[]) msgObj;
for (Object obj : msgArr) {
if (obj instanceof Map) {
Map<String, String> map = (Map<String, String>) obj;
String phone = map.get("phone");// 手机号
String text = map.get("text");// 回复内容
String date = map.get("date");// 日期
String extnum = map.get("Extnum");// 标识
// 将回复保存...
}
}
}
}
}
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<>();
}
}