## 注意事項
>只會獲取最新的回復,不可重復獲取,如二次獲取請聯系管理員
>
| 請求類型 | 請求地址 |
| --- | --- |
| 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<>();
}
}