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]; }

云片短信接口文档:

如有疑问请留言或者到本站社区交流讨论,感谢导语,愿望能赞助到大家,谢谢大家对本站的支持!

评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)

站点导航

您可能在找这些