Call NetEase cloud letter, realize SMS send
NetEase Cloud Letter Send SMS//http://dev.netease.im/docs?doc=server& #发送模板短信 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;//var_dump ($ data); $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), $result = Curl_exec ($ch); Curl_close ($ch); $resArr = (array) json_decode ($result); $RESARR = (array) json_decode (' {"Code": $, "msg": "Sendid", "obj": 1} ');//var_dump ($RESARR);//echo $resArr [' Code ']; return $RESARR; }
The above describes the PHP send text messages (call NetEase cloud Letter implementation), including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.