YP_SMS_KEY, 'mobile' => $params['mobile'], 'tpl_id' => $tpl_id, 'tpl_value' => ('#code#').'='.$params['code'], ]; $json_data = self::tpl_send($ch,$data); $array = json_decode($json_data,true); curl_close($ch); return $array; } public static function auditResultSend($params) { $tpl_id = '3910830'; //【酷炫】您的#business#审核已经完成,审核结果为#result#,点击#url#进行下一步操作 $ch = self::init(); $data = [ 'apikey' => YP_SMS_KEY, 'mobile' => $params['mobile'], 'tpl_id' => $tpl_id, 'tpl_value' => urlencode('#business#').'='.urlencode($params['business']).'&'.urlencode('#result#').'='.urlencode($params['result']).'&'.urlencode('#url#').'='.urlencode($params['url']) ]; $json_data = self::tpl_send($ch,$data); $array = json_decode($json_data,true); curl_close($ch); return $array; } public static function signVerify($params) { $tpl_id = '3910802'; //【合乐文化】#red#已经完成签约,请及时审核。 $ch = self::init(); $data = [ 'apikey' => YP_SMS_KEY, 'mobile' => $params['mobile'], 'tpl_id' => $tpl_id, 'tpl_value' => ('#red#').'='.urlencode($params['user_name']) ]; $json_data = self::tpl_send($ch,$data); $array = json_decode($json_data,true); curl_close($ch); return $array; } //账号审核提醒 public static function accountVerify($params) { $tpl_id = '3910796'; //【合乐文化】#red#已经完成账号注册,请尽快分配媒介,完成审核。 $ch = self::init(); $data = [ 'apikey' => YP_SMS_KEY, 'mobile' => $params['mobile'], 'tpl_id' => $tpl_id, 'tpl_value' => ('#red#').'='.urlencode($params['user_name']) ]; $json_data = self::tpl_send($ch,$data); $array = json_decode($json_data,true); curl_close($ch); return $array; } public static function sendVoiceCheck($phone,$code){ $ch=self::init(); $data=array('code'=>$code,'apikey'=>YP_SMS_KEY,'mobile'=>$phone); $json_data =self::voice_send($ch,$data); curl_close($ch); return $json_data; } private static function checkErr($result,$error) { if($result === false) { echo 'Curl error: ' . $error; } } private static function send($ch,$data){ curl_setopt ($ch, CURLOPT_URL, 'https://sms.yunpian.com/v2/sms/single_send.json'); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $result = curl_exec($ch); Log::info(json_encode($result)); $error = curl_error($ch); self::checkErr($result,$error); return $result; } private static function voice_send($ch,$data){ curl_setopt ($ch, CURLOPT_URL, YP_VOICE_URL); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $result = curl_exec($ch); Log::info(json_encode($result)); $error = curl_error($ch); self::checkErr($result,$error); return $result; } private static function tpl_send($ch,$data){ curl_setopt ($ch, CURLOPT_URL, YP_TPL_URL); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $result = curl_exec($ch); Log::info(json_encode($result)); $error = curl_error($ch); self::checkErr($result,$error); return $result; } //有参数发送短信验证码 public static function sendMsgWithParams($phone, $params, $template_id) { $ch=self::init(); $data=array('tpl_id' => $template_id,'apikey'=>YP_SMS_KEY,'mobile'=>$phone,'tpl_value'=>$params); $json_data = self::tplSend($ch,$data); $array = json_decode($json_data,true); curl_close($ch); return $array; } //无参数发送短信验证码 public static function sendMsgSimple($phone, $template_id) { $ch=self::init(); $data=array('tpl_id' => $template_id,'apikey'=>YP_SMS_KEY,'mobile'=>$phone); $json_data = self::tplSend($ch,$data); $array = json_decode($json_data,true); curl_close($ch); return $array; } private static function tplSend($ch,$data){ curl_setopt ($ch, CURLOPT_URL, 'https://sms.yunpian.com/v2/sms/tpl_single_send.json'); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $result = curl_exec($ch); Log::info(json_encode($result)); $error = curl_error($ch); self::checkErr($result,$error); return $result; } public static function sendOrderSyncMsg($params) { $tpl_id = '5370144'; //【酷炫网络】#msg#,请及时处理。 // $tpl_id = '4452336'; //【酷炫网络】#msg#,请及时处理。 $ch = self::init(); $data = [ 'apikey' => YP_SMS_KEY, 'mobile' => $params['mobile'], 'tpl_id' => $tpl_id, 'tpl_value' => ('#msg#').'='.urlencode($params['msg']) ]; $json_data = self::tpl_send($ch,$data); $array = json_decode($json_data,true); curl_close($ch); return $array; } }