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

开发技术 作者: 2024-08-16 11:25:01
这篇文章主要介绍了php版阿里大于(阿里大鱼)短信发送实现方法,结合实例形式分析了阿里大于短信发送接口的配置与使用技巧,需要的朋友可以参考下

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

通用函数

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; } @H_404_6@

优化

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; } @H_404_6@

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

配置模板

'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'),); @H_404_6@

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

原生类

extend = $extend; $this->apiParas["extend"] = $extend; } public function getExtend() { return $this->extend; } public function setRecNum($recNum) { $this->recNum = $recNum; $this->apiParas["rec_num"] = $recNum; } public function getRecNum() { return $this->recNum; } public function setSmsFreeSignName($smsFreeSignName) { $this->smsFreeSignName = $smsFreeSignName; $this->apiParas["sms_free_sign_name"] = $smsFreeSignName; } public function getSmsFreeSignName() { return $this->smsFreeSignName; } public function setSmsParam($smsParam) { $this->smsParam = $smsParam; $this->apiParas["sms_param"] = $smsParam; } public function getSmsParam() { return $this->smsParam; } public function setSmsTemplateCode($smsTemplateCode) { $this->smsTemplateCode = $smsTemplateCode; $this->apiParas["sms_template_code"] = $smsTemplateCode; } public function getSmsTemplateCode() { return $this->smsTemplateCode; } public function setSmsType($smsType) { $this->smsType = $smsType; $this->apiParas["sms_type"] = $smsType; } public function getSmsType() { return $this->smsType; } public function getApiMethodName() { return "alibaba.aliqin.fc.sms.num.send"; } public function getApiParas() { return $this->apiParas; } public function check() { RequestCheckUtil::checkNotNull($this->recNum,"recNum"); RequestCheckUtil::checkNotNull($this->smsFreeSignName,"smsFreeSignName"); RequestCheckUtil::checkNotNull($this->smsTemplateCode,"smsTemplateCode"); RequestCheckUtil::checkNotNull($this->smsType,"smsType"); } public function putOtherTextParam($key,$value) { $this->apiParas[$key] = $value; $this->$key = $value; } } @H_404_6@

更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》及《》

希望本文所述对大家PHP程序设计有所帮助。

原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_63184.html