PHP implementation to send SMS instances

Source: Internet
Author: User
Tags aliyun

This article mainly and everyone to share the PHP implementation to send SMS instances, mainly in the way of code and share with you, hope to help everyone.

1. Call the Alidayu tool class package, and then configure the parameters

  Public Function sendsms ($mobile, $content, $type, $pcode, $address) {include ("topsdk.php");    Date_default_timezone_set (' Asia/shanghai ');    $c = new \topclient ();            Switch ($type) {case ' 1 ': $c->appkey = "* * * *";            $c->secretkey = "************";            $req = new Alibabaaliqinfcsmsnumsendrequest;            $req = new \alibabaaliqinfcsmsnumsendrequest ();            $req->setsmstype ("normal");            $req->setsmsfreesignname ("Good Luck Life"); $req->setsmsparam ("{\" village\ ": \" ". $content." \ ", \" pcode\ ": \" ". $pcode." \ ", \" address\ ": \" ". $address."            \"}");            $req->setrecnum ($mobile);            $req->setsmstemplatecode ("sms_127161604");            $resp = $c->execute ($req);        Break            Default: $c->appkey = "* * * *";            $c->secretkey = "**********";            $req = new Alibabaaliqinfcsmsnumsendrequest;            $req = new \alibabaaliqinfcsmsnumsendrequest (); $req->setsmstype ("normal");            $req->setsmsfreesignname ("grab"); $req->setsmsparam ("{\" code\ ": \" ". $content."            \ ", \" product\ ": \" Shunshouna\ "}");            $req->setrecnum ($mobile);            $req->setsmstemplatecode ("sms_33580526");            $resp = $c->execute ($req);    Break    } if ($resp->result->success) {return true;    } else{return false; }}

2. Call the Sendsms method and proceed with processing.

$res = (new Aliyun ())->sendsms ($this->_param[' mobile '], $this->_param[' village '],1, $this->_param[' P_ Code '], $this->_param[' address ');

1. Call the Alidayu tool class package, and then configure the parameters

  Public Function sendsms ($mobile, $content, $type, $pcode, $address) {include ("topsdk.php");    Date_default_timezone_set (' Asia/shanghai ');    $c = new \topclient ();            Switch ($type) {case ' 1 ': $c->appkey = "* * * *";            $c->secretkey = "************";            $req = new Alibabaaliqinfcsmsnumsendrequest;            $req = new \alibabaaliqinfcsmsnumsendrequest ();            $req->setsmstype ("normal");            $req->setsmsfreesignname ("Good Luck Life"); $req->setsmsparam ("{\" village\ ": \" ". $content." \ ", \" pcode\ ": \" ". $pcode." \ ", \" address\ ": \" ". $address."            \"}");            $req->setrecnum ($mobile);            $req->setsmstemplatecode ("sms_127161604");            $resp = $c->execute ($req);        Break            Default: $c->appkey = "* * * *";            $c->secretkey = "**********";            $req = new Alibabaaliqinfcsmsnumsendrequest;            $req = new \alibabaaliqinfcsmsnumsendrequest (); $req->setsmstype ("normal");            $req->setsmsfreesignname ("grab"); $req->setsmsparam ("{\" code\ ": \" ". $content."            \ ", \" product\ ": \" Shunshouna\ "}");            $req->setrecnum ($mobile);            $req->setsmstemplatecode ("sms_33580526");            $resp = $c->execute ($req);    Break    } if ($resp->result->success) {return true;    } else{return false; }}

2. Call the Sendsms method and proceed with processing.

$res = (new Aliyun ())->sendsms ($this->_param[' mobile '], $this->_param[' village '],1, $this->_param[' P_ Code '], $this->_param[' address ');

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.