PHP建站技术分享-从入门到精通_各类知识收集PHP建站技术分享-从入门到精通_各类知识收集PHP建站技术分享-从入门到精通_各类知识收集

QQ:420220301 微信/手机:150-3210-7690
当前位置:首页 > 工作总结

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

管理员 2025-03-03
工作总结
0

《PHP编程:php版阿里大于(阿里大鱼)短信发送实例详解》要点:
本文介绍了PHP编程:php版阿里大于(阿里大鱼)短信发送实例详解,希望对您有用。如果有疑问,可以联系我们。
 

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

通用函数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;  }

优化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}");    switch($type) {      case 'sold':        $req->setSmsParam('{"name":"'. $data['name'] .'"}');        break;      case 'buysuccess':        $req->setSmsParam('{"name":"'. $data['name'] .'","product":"'. $data['product'] .'"}');        break;      case 'newagent':        $req->setSmsParam('{"name":"'. $data['name'] .'"}');        break;      default:         $req->setSmsParam('{"code":"'. $data['code'] .'","product":"'. $data['product'] .'"}');    }    $req->setRecNum("{$tel}");    $req->setSmsTemplateCode("{$templatecode}");    $resp = $c->execute($req);    return $resp;  }

这里的require 和 include_once 还是有区别的.如果用require,重复调用方法,就会报错.Fatal error: Cannot redeclare class.改成include_once 就可以了.PHP编程

配置模板PHP编程

<?phpreturn array ( // 阿里大鱼短信配置 'dayu_appkey'=>'xxxxxx', 'dayu_secretKey'=>'xxxxxxxxxxxxxxxxxxxxx', 'dayu_template_register' => array('signname'=>'注册验证','templatecode'=>'SMS_9655457'), 'dayu_template_alteration' => array('signname'=>'变更验证','templatecode'=>'SMS_9655454'), 'dayu_template_identity' => array('signname'=>'身份验证','templatecode'=>'SMS_9655461'), 'dayu_template_sold'=> array('signname'=>'点多多','templatecode'=>'SMS_12800188'), 'dayu_template_buysuccess'=> array('signname'=>'点多多','templatecode'=>'SMS_12775103'), 'dayu_template_newagent'=> array('signname'=>'点多多','templatecode'=>'SMS_12815193'),);

关于签名签名会显示在短信中【点多多】,只要是允许的签名,系统的或者自己审核通过的,可以混用.PHP编程



希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, LeCMS, ClassCMS, Fastadmin, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。

相关推荐

扫码关注

qrcode

QQ交谈

回顶部