zoukankan      html  css  js  c++  java
  • 阿里大鱼短信发送 FOR DT

    //增加了参数$action  来标志发送的是什么短信  注册短信  验证码短信  提示短信等
    function send_sms($mobile, $message, $word = 0, $time = 0,$action=0) {
        global $db, $DT, $DT_TIME, $DT_IP, $_username;
        if(!$DT['sms'] || !is_mobile($mobile) || strlen($message) < 5) return false;
        $word or $word = word_count($message);
        $sms_message = convert($message, DT_CHARSET, 'UTF-8'); 
        include DT_ROOT."/taobao-sdk/TopSdk.php"; 
        date_default_timezone_set('Asia/Shanghai'); 
        $c = new TopClient;
        //api 地址https://api.alidayu.com/docs/api.htm?spm=a3142.7629065.4.7.RoV088&apiId=25450 
        $c->appkey = 'yourappey';
        $c->secretKey = 'yoursecretKey';
        $req = new AlibabaAliqinFcSmsNumSendRequest;
        $req->setExtend("123456");    //可以带一个回传参数
        $req->setSmsType("normal");   //短信类型
        $req->setSmsFreeSignName("标签");//在阿里大鱼里设置好的标签
        $req->setSmsParam("{"code":"".$message."","product":"产品"}");
        $req->setRecNum($mobile);
        $temp="";
        switch($action){
            case 0:
              $temp="SMS_66725256"; //注册验证码  在ali大鱼上设置好的 需要参数 code
            break; 
            case 1:
              $temp="SMS_66770307"; //交易模板
            break;
            case 2:
              
            break;
            default:
            
            break;
        }
         
        $req->setSmsTemplateCode($temp);  //短信模板 SMS_5230182是注册模板
        
        $resp = $c->execute($req);  //默认返回xml 在taobao-sdk/top/TopClient.php 中修改
        //$xml=simplexml_load_string($resp);  直接返回的是xml解析后的数据,可以直接用$resp->code;
        $code ="";
        //var_dump($resp);
         
        $code=$resp->code;    //发送错误后code无值
         
        if($code!="") {
           //发送出错了,这里处理错误情况
            
        } else {
           //发送成功了
           $code="0";
        }
        $db->query("INSERT INTO {$db->pre}sms (mobile,message,word,editor,sendtime,code) VALUES ('$mobile','$message','$word','$_username','$DT_TIME','$code')");
        return $code;
    }
  • 相关阅读:
    Solution: Win 10 和 Ubuntu 16.04 LTS双系统, Win 10 不能从grub启动
    在Ubuntu上如何往fcitx里添加输入法
    LaTeX 笔记---Q&A
    Hong Kong Regional Online Preliminary 2016 C. Classrooms
    Codeforces 711E ZS and The Birthday Paradox
    poj 2342 anniversary party
    poj 1088 滑雪
    poj 2479 maximum sum
    poj 2481 cows
    poj 2352 stars
  • 原文地址:https://www.cnblogs.com/djiz/p/7510385.html
Copyright © 2011-2022 走看看