function getrandchar($length){ $str = null; $strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)]; } return $str; } $code = getrandchar(5); require_once(DEDEINC.'/aliyun-php-sdk-core/Config.php'); use Sms\Request\V20160927 as Sms; $iClientProfile = DefaultProfile::getProfile("cn-shenzhen", "your accessKey", "your accessSecret"); //登录阿里云查看: "your accessKey", "your accessSecret" $client = new DefaultAcsClient($iClientProfile); $request = new Sms\SingleSendSmsRequest(); $request->setSignName("签名");/*签名名称*/ $request->setTemplateCode("SMS_1111");/*模板code*/ $request->setRecNum($phone);/*目标手机号*/ $request->setParamString("{\"code\":\"$code\",\"tel\":\"电话号码\"}");/*模板变量,请确保跟审核过的短信模版变量一致,数字一定要转换为字符串*/ try { $response = $client->getAcsResponse($request); print_r($response); } catch (ClientException $e) { print_r($e->getErrorCode()); print_r($e->getErrorMessage()); } catch (ServerException $e) { print_r($e->getErrorCode()); print_r($e->getErrorMessage()); } $inquery = " INSERT INTO `dede_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$to','$code','1','$nowtime'); "; $rs = $dsql->ExecuteNoneQuery2($inquery); if( $rs = 1 ){ ShowMsg('发送成功,请注意查收!','-1'); exit(); } exit(); |
function getrandchar($length){ $str = null; //$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; $strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)]; } return $str; } $code = getrandchar(5); require_once(DEDEINC.'/alidayu-php-sdk/TopSdk.php'); $client = new TopClient; $client ->appkey = '111111' ; //登录阿里大于查看appkey。 $client ->secretKey = 'aaaaaaaaaaaaaa' ; //登录阿里大于查看secret。 $req = new AlibabaAliqinFcSmsNumSendRequest; $req ->setExtend( "" ); $req ->setSmsType( "normal" ); $req ->setSmsFreeSignName( "城子居" ); /*签名名称*/ $req ->setSmsParam( "{\"code\":\"$code\",\"name\":\"注册\"}" ); /*模板变量,请确保跟审核过的短信模版变量一致,数字一定要转换为字符串*/ $req ->setRecNum($phone);/*目标手机号*/ $req ->setSmsTemplateCode( "SMS_1111111" );//登录阿里大于查看/*模板ID编号*/ $resp = $client ->execute( $req ); $inquery = " INSERT INTO `imm_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$to','$code','1','$nowtime'); "; $rs = $dsql->ExecuteNoneQuery2($inquery); if( $rs = 1 ){ ShowMsg('发送成功,请注意查收!','-1'); exit(); } exit(); |
function getrandchar($length){ $str = null; //$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; $strPol = "0123456789"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)]; } return $str; } $number = getrandchar(4); require_once(DEDEINC.'/aliyun-php-sdk-core/Config.php'); require_once(DEDEINC.'/Dysmsapi/Request/V20170525/SendSmsRequest.php'); require_once(DEDEINC.'/Dysmsapi/Request/V20170525/QuerySendDetailsRequest.php'); function sendSms() { global $phone, $number; //此处需要替换成自己的AK信息 $accessKeyId = "yourAccessKeyId"; $accessKeySecret = "yourAccessKeySecret"; //短信API产品名 $product = "Dysmsapi"; //短信API产品域名 $domain = "dysmsapi.aliyuncs.com"; //暂时不支持多Region $region = "cn-beijing"; //初始化访问的acsCleint $profile = DefaultProfile::getProfile($region, $accessKeyId, $accessKeySecret); DefaultProfile::addEndpoint("cn-beijing", "cn-beijing", $product, $domain); $acsClient= new DefaultAcsClient($profile); $request = new Dysmsapi\Request\V20170525\SendSmsRequest; //必填-短信接收号码 $request->setPhoneNumbers($phone); //必填-短信签名 $request->setSignName("99商铺网"); //必填-短信模板Code $request->setTemplateCode("SMS_74725029"); //选填-假如模板中存在变量需要替换则为必填(JSON格式) $request->setTemplateParam("{\"number\":\"$number\"}"); //选填-发送短信流水号 $request->setOutId("1234"); //发起访问请求 $acsResponse = $acsClient->getAcsResponse($request); } sendSms(); $inquery = " INSERT INTO `imm_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$phone','$number','1','$nowtime'); "; $rs = $dsql->ExecuteNoneQuery2($inquery); if( $rs = 1 ){ echo "发送成功,请注意查收!"; exit(); } exit(); |
function getrandchar($length){ $str = null; $strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)]; } return $str; } require_once(DEDEINC.'/ucpaas.class.php'); $options['accountsid']=''; //对应ucpaas.com用户ID $options['token']=''; //对应ucpaas.com里面的用户token $ucpass = new Ucpaas($options); $appId = ""; //对应ucpaas.com里面的项目ID $to = $phone; $templateId = ""; //对应ucpaas.com里面的短信模版ID $code = getrandchar(5); $param= $code.',短信模版参数2'.',短信模版参数3'; // $code为生成的验证码,短信模版参数2,短信模版参数3,参数之间用英文逗号间隔。 $ucpass->templateSMS($appId,$to,$templateId,$param); $inquery = " INSERT INTO `dede_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$to','$code','1','$nowtime'); "; $rs = $dsql->ExecuteNoneQuery2($inquery); if( $rs = 1 ){ ShowMsg('发送成功,请注意查收!','-1'); exit(); } exit(); |