阿里大于(鱼),配置教程

2017-3-31 admin 其它

1.创建应用 (应用管理-创建应用)

2.jpg

2.添加签名 (配置管理-验证码)

3.jpg

3.配置短信模版 (配置管理-验证码)

5.jpg

4.测试用用

1.jpg

5.下载SDK(PHP版本) 

12.jpg

6. Alidayu文件夹下创建 index.php

 

<?php
 include "TopSdk.php";
 date_default_timezone_set('Asia/Shanghai');

 $code = $_GET['code'];
 $phone = $_GET['phone'];

 $c = new TopClient;
 $c ->appkey = "11111111" ; //需更换
 $c ->secretKey = "adsfasdf2as2df2asdf2asf2" ; //需更换
 $req = new AlibabaAliqinFcSmsNumSendRequest;
 $req ->setExtend( "" );
 $req ->setSmsType( "normal" );
 $req ->setSmsFreeSignName( "我的Apps" );
 $req ->setSmsParam( "{code:'$code'}" );
 $req ->setRecNum( $phone );
 $req ->setSmsTemplateCode( "SMS_45665224" );
 $resp = $c ->execute( $req );
 echo $resp->result->success;
?>

把Alidayu文件夹上传到服务器上,此时可以访问 http://你的网站/Alidayu/index.php?code=1111&phone=13800138000

这时候就可以把验证码1111发送到13800138000了(发送成功会返回true)


*注意:index.php编码方式必须为UTF-8

 

 

可以thinkphp控制器来做接口(Thinkphp3.1.3)

 

<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action {
    public function index(){
 $this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
    }
 public function sendMsm(){
  $code = $_GET['code'];
  $phone = $_GET['phone'];

  $url = "http://你的网站/Alidayu/index.php?phone=".$phone."&code=".$code;
  
  $data = $this->request_interface('http','get',$url,'');
  echo $data;
 }
 //模拟请求
 function request_interface($path,$type,$url,$data){
 //初始化
 $ch = curl_init();
 curl_setopt($ch,CURLOPT_URL,$url);
 
 if($path == 'https'){
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
  curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
 }
 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
 
 if($type == 'post'){
  // post数据
  curl_setopt($ch,CURLOPT_POST,1);
  // post的变量
  curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
 }else{
  curl_init($ch,CURLOPT_HEADER,0); //头信息
 }
 $output = curl_exec($ch);
 curl_close($ch);
 //打印获得的数据
 return $output;
 //print_r($output);
 
 }
}
?>

 

标签: 阿里大于 短信验证 阿里大鱼

发表评论:

Powered by emlog 吉ICP备15003877号