| 请求类型 | 请求地址 |
| --- | --- |
| POST/GET | http://api.laosan6.com/Api/sms |
| 参数名 | 类型 | 描述 |
| --- | --- | --- |
| username | String | 用户名 |
| password | String | 用户密码 |
| userkey | String | 用户密钥|
| type | String | 类型(code:验证码,key:卡密) |
| phone | String | 手机号 |
| code | String | 验证码 |
```
请求成功 -> 返回码
{
"code": "ok",
"msg": "发送成功",
}
```
~~~
请求失败 -> 返回码
{
"code": "no",
"msg": "错误信息",
}
~~~
|msg | 对应信息 |
| --- | --- |
| User does not exist | 用户不存在 |
| Password error | 用户密码错误 |
| Domain name not authorized | 请求域名不符 |
| Insufficient number of money | 用户余额不足 |
| Key error| 密钥有误 |
| user ban | 用户被禁封 |
| .... | 不必要信息 ... |
~~~
参照代码(POST)
~~~
~~~
<?php
$url = 'http://api.laosan6.com/Api/sms';
$phone = '手机号';
$code = '验证码';
$type = 'code'; //(code:验证码,key:卡密)
$postdata = [
'username' => '用户名',
'password' => '用户密码',
'userkey' => '用户key',
'type' => $type,
'code' => $code,
'phone' => $phone
];
$result = request_post($url,$postdata);
$status = json_decode($result,true);
if($status['code'] != 'ok'){
//加密失败,参考返回码 对应信息
}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;
}
~~~
~~~
参照代码(GET)
~~~
~~~
<?php
$url = 'http://api.laosan6.com/Api/sms';
$phone = '手机号';
$code = '验证码';
$type = 'code'; //(code:验证码,key:卡密)
$username = '用户名';
$password = '用户密码';
$userkey = '用户KEY';
$result = file_get_contents($url.'?username='.$username.'&password='.$password.'&userkey='.$userkey.'&phone='.$phone.'&type='.$type.'&code='.$code);
$status = json_decode($result,true);
if($status['code'] != 'ok'){
//发送失败,参考返回码 对应信息
}else{
//发送成功,自行进行下一步操作
}
~~~