```bash
//短信发送
public function sendMsm()
{
$code =mt_rand(10000,99999);
$url = "http://intapi.253.com/send/json";
//headers数组内的格式
// 参数
$data['msg'] = $code.'你的模版';
$data['mobile'] = input('mobile');
$data['account'] = API账户;
$data['password'] = AP密钥;
$res = $this->curlPost($url,$data);
if(json_decode($res,true)['code']=='0'){
return $code;
};
}
private function curlPost($url, $postFields)
{
$postFields = json_encode($postFields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8'
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$ret = curl_exec($ch);
if (false == $ret) {
$result = curl_error($ch);
} else {
$rsp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (200 !== $rsp) {
$result = "请求状态 " . $rsp . " " . curl_error($ch);
} else {
$result = $ret;
}
}
curl_close($ch);
return $result;
}```