文档中心

新手指南 / 服务介绍 / 接口说明 / 代码示例 / 注意事项

php

示例中验证部分username固定为api,password格式为key-32位KEY,各位的KEY可在后台短信或语音->触发发送下查看、更改

发送短信
发送语音

发送短信

请求
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://sms-api.luosimao.com/v1/send.json");

curl_setopt($ch, CURLOPT_HTTP_VERSION  , CURL_HTTP_VERSION_1_0 );
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_HTTPAUTH , CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD  , 'api:key-b761c24f77fc5d77769d5a442ccacc10');

curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('mobile' => '13761428267','message' => '验证码:123456【铁壳测试】'));

$res = curl_exec( $ch );
curl_close( $ch );
//$res  = curl_error( $ch );
var_dump($res);

 

返回结果
{"error":0,"msg":"ok"}

 

获取短信余额

请求
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL , "http://sms-api.luosimao.com/v1/status.json");
curl_setopt($ch, CURLOPT_HTTP_VERSION  , CURL_HTTP_VERSION_1_0 );
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

curl_setopt($ch, CURLOPT_HTTPAUTH , CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD  , 'api:key-b761c24f77fc5d77769d5a442ccacc10');

$res =  curl_exec( $ch );
curl_close( $ch );
//$res  = curl_error( $ch );
var_dump($res);

 

返回结果
{"error":0,"deposit":"1119987446"}

发送语音

请求
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://voice-api.luosimao.com/v1/verify.json");

curl_setopt($ch, CURLOPT_HTTP_VERSION  , CURL_HTTP_VERSION_1_0 );
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_HTTPAUTH , CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD  , 'api:key-b761c24f77fc5d77769d5a442ccacc10');

curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('mobile' => '13761428267','code' => '123456'));

$res = curl_exec( $ch );
curl_close( $ch );
//$res  = curl_error( $ch );
var_dump($res);

 

返回结果
{"error":0,"msg":"ok"}

 

获取语音余额

请求
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL , "http://voice-api.luosimao.com/v1/status.json");
curl_setopt($ch, CURLOPT_HTTP_VERSION  , CURL_HTTP_VERSION_1_0 );
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

curl_setopt($ch, CURLOPT_HTTPAUTH , CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD  , 'api:key-b761c24f77fc5d77769d5a442ccacc10');

$res =  curl_exec( $ch );
curl_close( $ch );
//$res  = curl_error( $ch );
var_dump($res);

 

返回结果
{"error":0,"deposit":"1119987446"}

 

 

短信php library下载:

sms_php_lib.zip

 

会员贡献

sms composer 

https://packagist.org/packages/leslie/sms

https://github.com/Leslie1sMe/LuosimaoSms

来自:Leslie

 

 

微信客服
立即咨询
客服热线:
021-60193106
服务时间:
9:00-18:00
(周日除外)