Ali Big Fish SMS Interface Integration Tp3.2.3 development and finishing

Source: Internet
Author: User
Tags sendmsg

Ali Big Fish http://www.alidayu.com/SMS interface Overall is good, do not An Shu personally think whether it is from the price or stability are with the same kind of SMS interface better, after all, is the big company's things will not be bad to where to go. The following is a pre-developed SMS interface to do a collation.

1, login Ali Big Fish Management Center add their own applications, and then use what template please submit the audit, here do not say long.

2, the core steps, to organize Ali big fish to give the PHP sample core package, but don't An Shu already for you to clean up only need to download the core package portal (PS: Extract password: http://www.bieanju.com/).

3, the foreground call sends a text message using AJAX asynchronous request processing send,

3.1, of course, here will first use some public configuration, so first look at the configuration:

    /*/array(        ' Appkey ' = ' xxxx ',        ' secretkey ' = ' xxxx ',        ' smstemplate ' = ' sms_xxx ',//  Registration hint template number        ' signname ' +    ' Test sms ',        ' Product '    = ' and ' Don't An Shu test sms content ',        ' Expire '        + ', '

3.2, the background Send SMS method (PS: can be written as a public function, after all, the place to send text messages more than registration, may need to change the password or retrieve the password will be used):

The sending method of the call
Publicfunction mobilevalid () { $mobile = I (' mobile '); echo sendmobilecode ($mobile);}
/** Ali Big Fish Mobile Verification code send function * **/    functionSendmobilecode ($mobile) {Vendor (' Alidayu.client '); Vendor (' Alidayu.sendsms '); Vendor (' Alidayu.resultset '); Vendor (' Alidayu.requestcheckutil '); Vendor (' Alidayu.toplogger '); $client=NewClient (); $client->appkey = C (' Alidayu.appkey '); $client->secretkey = C (' Alidayu.secretkey '); /*assembly send pre-parameters*/        $code= Randcode (4); $send _msg=Array(' Code ' =$code, ' Product ' =>c (' alidayu.product '), ' Item ' =>c (' alidayu.product ')); $request=Newsendsms (); $request->setextend ($mobile); $request->setsmstype ("normal"); $request->setsmsfreesignname (C (' Alidayu.signname ')); $request->setsmsparam (Json_encode ($send _msg)); $request->setrecnum ($mobile); $request->setsmstemplatecode (C (' Alidayu.smstemplate ')); $result= Json2array (Json_encode ($client->execute ($request))); if($result[' Result '] [' Success ']) {Cookie (' Mobile_validated ',$code, C (' Alidayu.expire ')); $msg=Array(' status ' + 1, ' info ' = ' + ' Verification code has been sent to your phone! "); }Else{            $msg=Array(' status ' = 0, ' info ' = ' Verification code sent failed, '.$result[' Sub_msg ']. " Please try again later! "); }        returnJson_encode ($msg); }

3.3, the foreground call is mainly Ajax write function processing to send text messages and countdown:

var Mobileurl = "Processing method address for sending SMS";
$(function() {$ (' #sendmsg '). Click (function(){ varMobile = $ ("Input[name= ' mobile ']"). Val (); varURL =Mobileurl; Curcount=count; if(!mobile) {Layer.msg ("Sorry, please fill in the phone number first"); return false; } $.get (Mobileurl,{mobile:mobile},function(JSON) {JSON= eval ("(" +json+ ")"); if(json.status) {intervalobj= Window.setinterval (setremaintime, 1000); Layer.msg (Json.info); }Else{layer.msg (json.info); } }) })})functionSetremaintime () {if(Curcount = = 0) {window.clearinterval (intervalobj);//Stop Timer$ ("#sendmsg"). Removeattr ("Disabled");//Enable button$ ("#sendmsg"). HTML ("Resend Verification Code"); $("#sendmsg"). CSS ("Background", "#FAEBC4")); }Else{Curcount--; $("#sendmsg"). HTML (curcount+ "re-send after seconds"); $("#sendmsg"). attr ("Disabled", "disabled"); $("#sendmsg"). CSS ("Background", "#E8E6E0")); }}

OK, the SMS template has been sent successfully! Isn't it simple? Ha ha......

Ali Big Fish SMS Interface Integration Tp3.2.3 development and finishing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.