精简版阿里大鱼短信接口短信SMS发送接口PHP实例

php发送短信(调用网易云信实现)

调用网易云信,实现短信发送

//网易云信发送短信 //http://dev.netease.im/docs?doc=server&#发送模板短信 function yx_sendsms($mobile='',$para

<?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>

Thinkphp连系网易云IM代码类分享

使用网易云IM做APP可以实现私聊、群聊、聊天室等通讯能力功能,网易云IM文档看起来比较复杂,很多新手不知道如何入手,今天跟版网总结一下,分享给大家学习使用。

1.封装的类如下:

转载请说明出处内容投诉
八爷源码网 » 精简版阿里大鱼短信接口短信SMS发送接口PHP实例