This article describes the PHP version of Ali greater than (Ali Big fish) Message delivery implementation method. Share to everyone for your reference, as follows:
General functions
Send more than SMS 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; }
Optimize
Send more than SMS 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; }
There is a difference between the require and the include_once here. If you use require, repeat the call method, you will get an error. Fatal Error:cannot Redeclare class. You can change it into a include_once.
Configure templates
<?phpreturn Array (//Ali Big Fish SMS configuration ' dayu_appkey ' = ' xxxxxx ', ' dayu_secretkey ' = ' xxxxxxxxxxxxxxxxxxxxx ', ' dayu_ Template_register ' = = Array (' signname ' = ' Registration verification ', ' templatecode ' = ' sms_9655457 '), ' Dayu_template_ Alteration ' = = Array (' signname ' = ' Change verification ', ' templatecode ' = ' sms_9655454 '), ' dayu_template_identity ' = Array (' signname ' = ' + ' authentication ', ' templatecode ' = ' sms_9655461 '), ' dayu_template_sold ' = = Array (' signname ' = = ') Dot Toto ', ' templatecode ' = ' sms_12800188 '), ' dayu_template_buysuccess ' = = Array (' signname ' + ' dot toto ', ' Templatecode ' + ' sms_12775103 '), ' dayu_template_newagent ' = = Array (' signname ' + ' dot toto ', ' templatecode ' = ') sms_12815193 '),);
About signature signature will be displayed in the text message "dot more", as long as the allowed signature, the system or self-audit through, can be mixed.
Native class
<?php/** * TOP API:alibaba.aliqin.fc.sms.num.send Request * * @author Auto Create * @since 1.0, 2015.12.02 */class Ali babaaliqinfcsmsnumsendrequest{/** * Public callback parameter, in "message return" will be passed back to the parameter; For example: the user can pass in their subordinate member ID, when the message returns, the member ID will be included, The user can identify which member used your app **/private $extend based on the member ID; /** * SMS receive number. Support for single or multiple mobile phone numbers, incoming number is 11-digit mobile phone number, can not add 0 or 86. Mass text messages need to pass in multiple numbers, separated by commas, and a maximum of 200 numbers are passed in a single call. Example: 18600000000,13911111111,13322222222 **/private $recNum; /** * SMS signature, incoming SMS signature must be the available signature in Ali Big Fish "Admin Center-SMS Signature Management". such as "Ali Big Fish" has been in the SMS signature management through the audit, you can pass in "Ali Big Fish" (pass the argument when the quotation marks) as a text message signature. SMS Effect Example: "Ali big Fish" Welcome to use Ali Big Fish service. **/private $smsFreeSignName; /** * Short Message template variables, parameter rules {"Key": "Value" the name of the},key must match the variable name in the application template, and multiple variables are separated by commas. Example: For the template "Verification code $[code", you are in the ${product} authentication, kill do not tell others Oh! ", the parameter must be passed {" Code ":" 1234 "," Product ":" Alidayu "} **/private $smsParam; /** * SMS Template ID, the incoming template must be in the Ali Big Fish "Admin Center-SMS Template Management" in the available templates. Example: sms_585014 **/private $smsTemplateCode; /** * SMS type, incoming value please fill in normal **/private $smsType; Private $apiParas = Array (); Public Function Setextend ($extend) {$this->extend =$extend; $this->apiparas["extend") = $extend; } public Function Getextend () {return $this->extend; The Public Function Setrecnum ($recNum) {$this->recnum = $recNum; $this->apiparas["rec_num") = $recNum; } public Function Getrecnum () {return $this->recnum; The Public Function Setsmsfreesignname ($smsFreeSignName) {$this->smsfreesignname = $smsFreeSignName; $this->apiparas["sms_free_sign_name") = $smsFreeSignName; } public Function Getsmsfreesignname () {return $this->smsfreesignname; The Public Function Setsmsparam ($smsParam) {$this->smsparam = $smsParam; $this->apiparas["Sms_param") = $smsParam; } public Function Getsmsparam () {return $this->smsparam; The 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"); The Public Function Putothertextparam ($key, $value) {$this->apiparas[$key] = $value; $this $key = $value; }}
The above is the PHP version of Ali greater than (Ali Big fish) text message to send a detailed example of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!