News新闻

业界新闻动态、技术前沿
Who are we?

您的位置:首页      乐道系统FAQ      php版阿里大于(阿里大鱼)短信发送实例详解

php版阿里大于(阿里大鱼)短信发送实例详解

发布日期:2016-11-30 00:00:00 265

本文实例讲述了php版阿里大于(阿里大鱼)短信发送实现方法。分享给大家供大家参考,具体如下:

通用函数

// 发送大于短信 更牛逼的
  protected function sendDayuSmsPlus($tel,$type,$data) {
    $dayu_template = 'dayu_template_'.$type;
    $signname = C($dayu_template.".signname");
    $templatecode = C($dayu_template.".templatecode");
    // require LIB_PATH . 'ORG/Taobao-sdk-php/TopSdk.php';
    include_once LIB_PATH . 'ORG/Taobao-sdk-php/TopSdk.php';
    $c = new TopClient;
    $c->appkey = C('dayu_appkey');
    $c->secretKey = C('dayu_secretKey');
    $req = new AlibabaAliqinFcSmsNumSendRequest;
    $req->setSmsType("normal");
    $req->setSmsFreeSignName("{$signname}");
    if ($type == 'sold') {
      $req->setSmsParam('{"name":"'. $data['name'] .'"}');
    }
    if ($type == 'buysuccess') {
      $req->setSmsParam('{"name":"'. $data['name'] .'","product":"'. $data['product'] .'"}');
    }
    if ($type == 'newagent') {
      $req->setSmsParam('{"name":"'. $data['name'] .'"}');
    }
    $req->setRecNum("{$tel}");
    $req->setSmsTemplateCode("{$templatecode}");
    $resp = $c->execute($req);
    return $resp;
  }