示例中验证部分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"}
sms composer
https://packagist.org/packages/leslie/sms
https://github.com/Leslie1sMe/LuosimaoSms
来自:Leslie