生活随笔
收集整理的這篇文章主要介紹了
php发送短信(调用网易云信实现)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
調用網易云信,實現(xiàn)短信發(fā)送
[php]? view plain copy
?? ????? ???function?yx_sendsms($mobile='',$params='',$templateid=''){?? ???????header("Content-Type:text/html;?charset=utf-8");?? ???????$AppKey?=?'xxx';?? ???????$AppSecret?=?'xxx';?? ???????$Nonce?=?rand(100000,999999);?? ???????$CurTime?=?time();?? ???????$CheckSum?=?strtolower(sha1($AppSecret.$Nonce.$CurTime));?? ???????$url?=?'https://api.netease.im/sms/sendtemplate.action';?? ???????$head_arr?=?array();?? ???????$head_arr[]?=?'Content-Type:?application/x-www-form-urlencoded';?? ???????$head_arr[]?=?'charset:?utf-8';?? ???????$head_arr[]?=?'AppKey:'.$AppKey;?? ???????$head_arr[]?=?'Nonce:'.$Nonce;?? ???????$head_arr[]?=?'CurTime:'.$CurTime;?? ???????$head_arr[]?=?'CheckSum:'.$CheckSum;?? ???????$data?=?array();?? ????$data['templateid']?=?$templateid;?? ????$data['mobiles']?=?$mobile;?? ????$data['params']?=?$params;?? ?????? ?? ????$ch?=?curl_init();?? ????curl_setopt($ch,?CURLOPT_URL,?$url);?? ????curl_setopt($ch,?CURLOPT_RETURNTRANSFER,?true);?? ????curl_setopt($ch,?CURLOPT_POST,?true);?? ????curl_setopt($ch,?CURLOPT_HTTPHEADER,?$head_arr);?? ????curl_setopt($ch,?CURLOPT_POSTFIELDS,?http_build_query($data));?? ????curl_setopt($ch,?CURLOPT_TIMEOUT,?120);?? ????$result?=?curl_exec($ch);????????? ????curl_close($ch);?? ????$resArr?=?(array)?json_decode($result);?? ????????? ?????? ?????? ????return?$resArr;?? ???} ?
總結
以上是生活随笔為你收集整理的php发送短信(调用网易云信实现)的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。