相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
php調(diào)用云片網(wǎng)接口發(fā)送短信的實現(xiàn)方法
php調(diào)用云片網(wǎng)接口發(fā)送短信的實現(xiàn)方法
云片網(wǎng)發(fā)送短信
/** * [SendSms description] * @param [string] $tpl_content [發(fā)送的短信內(nèi)容] * @param $send_mobile [發(fā)送的手機號碼] */ public function SendSms($tpl_content,$send_mobile) { $this->yunpian_appkey = env('yunpian_appkey');//云片賬戶appkey $this->yunpian_secret = env('yunpianSecretXYZ');//云片賬戶secret //初始化 $ch = curl_init(); $data=array('text'=>$tpl_content,'apikey'=>$this->yunpian_appkey,'mobile'=>$send_mobile); curl_setopt ($ch, CURLOPT_URL, 'https://sms.yunpian.com/v2/sms/single_send.json'); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:text/plain;charset=utf-8', 'Content-Type:application/x-www-form-urlencoded', 'charset=utf-8')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $send_data = curl_exec($ch); curl_close($ch); //解析返回結(jié)果(json格式字符串) $backmassage = json_decode($send_data,true); echo '$backmassage '; //這里是寫在了job里面所以記了個日志可忽略! Log::info('smsmessagelog: '.$send_data); return [$backmassage,$send_data]; }