php調用云片網接口發送短信的實現法子

更新:2017-10-27    編輯:落煙灰    來源:會員投稿    人氣:加載中...    字號:|

標簽:實現  調用  方法  接口  短信  發送  百度搜索

php調用片網接口發送短信實現法子

片網發送短信

/** * [SendSms description] * @param [string] $tpl_content [發送的短信內容] * @param $send_mobile [發送的手機號碼] */ 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); //解析返回結果(json款式字符串) $backmassage = json_decode($send_data,true); echo '$backmassage '; //這里是寫在了job里面所以記了個日志可漠視! Log::info('smsmessagelog: '.$send_data); return [$backmassage,$send_data]; }

云片短信接口文檔:

如有疑問請留言或者到本站社區交流討論,感謝導語,愿望能贊助到大家,謝謝大家對本站的支持!

評論列表(網友評論僅供網友表達個人看法,并不表明本站同意其觀點或證實其描述)

站點導航

您可能在找這些
黑龙江快乐十分走势图