名站网址导航为大家免费提供关于网站编程方面的知识。
Thinkphp结合网易云IM具体相关代码如下类分享
- 本篇文章的具体介绍如下请大家仔细看
<?php header("Content-Type:text/html;charset=gb2312"); //签名函数 function createSign ($paramArr) { global $appSecret; $sign = $appSecret; ksort($paramArr); foreach ($paramArr as $key => $val) { if ($key != '' && $val != '') { $sign .= $key.$val; } } $sign.=$appSecret; $sign = strtoupper(md5($sign)); return $sign; } //组参函数 function createStrParam ($paramArr) { $strParam = ''; foreach ($paramArr as $key => $val) { if ($key != '' && $val != '') { $strParam .= $key.'='.urlencode($val).'&'; } } return $strParam; } ?><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>短信发送</title> <style type="text/css"> /*自定义css*/ body{font-family:Georgia,仿宋_GB2312, Arial, helvetica, sans-serif;} table {margin:0 auto;width:468px;} td{padding:1px;text-align:center;} td span{font-size:14px;padding:1px;} #m_,#n_{color:red;} span,i{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:block;} i{width:320px;background:#e5f2fa;font-size:24px;font-weight:600;} hr{PAGE-BREAK-AFTER:always;hEIGhT:0px;width:0px;margin:0;} </style> </head> <body> <script language="javascript"> var $=function(node){ return document.getElementById(node); } function $(objId){ return document.getElementById(objId); } function startRequest(Num) { var queryString; var ms=$("m").value.replace(/(^\s )|(\s $)/g, "");//去除前后的空格 var ns=$("n").value.replace(/(^\s )|(\s $)/g, "");//去除前后的空格 if(Num == 3 || Num == 0){ if (!ms.match(/^1[34578][\d]{9}$/)){ $('m').style.borderColor='red'; $("m_").innerhTML="请输入正确手机号!"; return false; }else{ $('m').style.borderColor='green'; $("m_").innerhTML="OK!"; } } if(Num == 4 || Num == 0){ if (!ns.match(/^[0-9]{6}$/)){ //if($("n").value == ""){ $('n').style.borderColor='red'; $("n_").innerhTML="请输入6位数字验证码!"; return false; }else{ $('n').style.borderColor='green'; $("n_").innerhTML="OK!"; } } if(Num == "0"){ //$("sub").submit(); //return false; } } </script> <?php $mm=$_POST['m']; $nn=$_POST['n']; $randkey= rand(111000,999888); if(!$mm){ }else{ //修改以下参数为你的参数(正确修改才可以正常使用) //********************************************************** //以下俩项目:https://www.alidayu.com/center/application/list点击对应项目后查看 $appKey = '232788888'; $appSecret = '12345678900000000'; //在这个页面查看短信模板:https://www.alidayu.com/center/tpl/list/code $template_code = 'SMS_2505450'; //在这个页面查看短信签名:https://www.alidayu.com/center/sign/list/code $sinname= '身份验证'; // $product= '微信公众号绑定身份验证'; //********************************************************** //以下不用管 $sinname= iconv('GB2312', 'UTF-8', $sinname); $product= iconv('GB2312', 'UTF-8', $product); $sinnames= urlencode($sinname); $products= urlencode('{"code":"'.$randkey.'","product":"'.$product.'"}'); $sinnames= $sinname; $products= '{"code":"'.$nn.'","product":"'.$product.'"}'; //参数数组 $paramArr = array( 'app_key' => $appKey, 'method' => 'alibaba.aliqin.fc.sms.num.send', 'format' => 'xml', 'v' => '2.0', 'sms_type' => 'normal', 'sign_method'=>'md5', 'timestamp' => date('Y-m-d h:i:s'), 'extend' => ''.$randkey.'', 'rec_num' => ''.$mm.'', 'sms_free_sign_name' => ''.$sinnames.'', 'sms_param' => ''.$products.'', 'sms_template_code' => ''.$template_code.'' ); //生成签名 $sign = createSign($paramArr); //组织参数 $strParam = createStrParam($paramArr); $strParam .= 'sign='.$sign; //访问服务 $url = 'http://gw.api.taobao.com/router/rest?'.$strParam; //沙箱环境调用地址 $result = file_get_contents($url); //$result = json_decode($result); echo "<br>'.$result.'<br>"; //print_r($result); } ?> <table border="0" cellpadding="0"> <form id="form" name="form" method="post" action="" onsubmit="return startRequest(0);"> <tr> <td style="width:120px;"> 手机号: </td> <td> <input name="m" type="text" id="m" style="width:100%;" onBlur="startRequest(3)" /><span id="m_"></span> </td> </tr> <tr> <td style="width:120px;"> 验证码: </td> <td> <input name="n" type="text" id="n" style="width:100%;" onBlur="startRequest(4)" value="<?php echo $randkey; ?>" /><span id="n_"></span> </td> </tr> <tr> <td colspan="2" bgcolor="#FFFFFF"> <input type="submit" name="Submit3" value=" 发送短信 " /> </td> </tr> </form> </table> </body> </html> |
关于网站编程方面的知识就说道这里了,希望能够对大家有作用。,精简版,阿里,大鱼,短信,接口,SMS,发送,PhP,实例,