$content = 'Your verification code 123456, this verification code is valid within 30 minutes, do not leak to others!' ;
$mobile = '93*****08' ;
$request_id = $this->send_sms_wu('998'.$mobile,$content);
$this->get_sms_status($request_id);
public function api_test($data,$user){
$content = 'Your verification code 123456, this verification code is valid within 30 minutes, do not leak to others!' ;
$request_id = $this->send_sms_wu('998'.$mobile,$content);
$this->get_sms_status($request_id);
echo '成功';exit;
}
public function send_sms_wu($mobile,$text){
$wu = [
'mobile' => $mobile ,
'text' => $text ,
] ;
error_log(date('Y-m-d H:i:s') . ' 发送验证码 ' . json_encode($wu, 320) . ' ' . PHP_EOL, 3, '../runtime/sms_wu.log');
$login = '*****' ;
$password = 'M71************9J' ;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://185.8.212.184/smsgateway/');
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_POSTFIELDS,
'login='.urlencode($login).
'&password='.urlencode($password).
'&data='.urlencode('[
{"phone":"'.$mobile.'", "text":"'.$text.'"}
]'));
curl_setopt($curl, CURLOPT_USERAGENT, 'Opera 10.00');
$res = curl_exec($curl);
error_log(date('Y-m-d H:i:s') . ' 发送验证码 $res ' . json_encode($res, 320) . ' ' . PHP_EOL, 3, '../runtime/sms_wu.log');
echo $res;
curl_close($curl);
exit ;
}
public function get_sms_status($request_id){
error_log(date('Y-m-d H:i:s') . ' 获取验证码状态 $request_id ' . json_encode($request_id, 320) . ' ' . PHP_EOL, 3, '../runtime/sms_wu.log');
$login = '*****' ;
$password = 'M71************9J' ;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://185.8.212.184/smsgateway/status/');
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_POSTFIELDS,
'login='.urlencode($login).
'&password='.urlencode($password).
'&data='.urlencode('[{"request_id":"'.$request_id.'"}]'));
curl_setopt($curl, CURLOPT_USERAGENT, 'Opera 10.00');
$res = curl_exec($curl);
error_log(date('Y-m-d H:i:s') . ' 获取验证码状态 $res ' . json_encode($res, 320) . ' ' . PHP_EOL, 3, '../runtime/sms_wu.log');
echo $res;
curl_close($curl);
exit;
}