/** * Send cell phone message class, Verification code retrieve password lesson reminders and so on use micron SMS platform Micron Official document instance http://www.weimi.cc/example-php.html* @author Panchengze 2015-01-20*/cl Sendmobilemessage{private $_api_address = ' http://api.weimi.cc/2/sms/send.html ';//micron API call address private $_uid = ' Gcxs423gda1h9j ';p rivate $_password = ' ada12324 ';p rivate $_packagedparam = ';/** * send * @return micron return result json */public fun ction Send ($mobiles, $cid, $param, $type = ' json ') {$this->_packageparam ($mobiles, $cid, $param, $type);//package parameter $ch = cur L_init (); curl_setopt ($ch, Curlopt_url, $this->_api_address); curl_setopt ($ch, Curlopt_returntransfer, TRUE); curl _setopt ($ch, Curlopt_post, TRUE); curl_setopt ($ch, Curlopt_postfields, $this->_packagedparam); $res = Curl_exec ($ch ); Curl_close ($ch); return $res;} /** * Assembly sent parameters * @param $mobiles A comma-delimited example of the phone number to be sent to: 139********,138******** * @param $cid SMS Template CID, created through the micron background, audited by the online customer service. Must set up a good text message signature, signature specification: * 1), template content must be signed, the signature is placed in the front of the template content; * 2), signature format: "* * *", the signature content of three characters or more (including three); * 3), text message content does not allow double signature, that is, the content of the * @param $param Incoming template parametersNumber. Sample text message template content: * "Micron" Your Verification code is:%p%,%p% minutes in effect. If you do not, you can ignore this message. * Pass in two parameters: * Array (' P1 ' =>610912, ' P2 ' =>3, ...) if a parameter is directly passed the value can be * final send content: * "Micron" Your Verification code is: 610912, 3 minutes in effect. If you do not, you can ignore this message. * @param $type Send type Josn * return string */private function _packageparam ($mobiles, $cid, $param, $type) {$this->_packa Gedparam = ' uid= '. $this->_uid. ' &pas= '. $this->_password. ' &mob= '. $mobiles. ' &cid= '. $cid, if (Is_array ($param)) {foreach ($param as $k = = $v) {$this->_packagedparam. = ' & '. $k. '=' . $v;}} else {$this->_packagedparam. = ' &p1= '. $param;} $this->_packagedparam. = ' &type=json ';}} $sendMobileMessage = new Sendmobilemessage (); $sendMobileMessage->send (' 18821536122 ', ' whkfjj65y13d ', ' 123456 ');
The PHP instance given by Micron is encapsulated for reference only
Micron Platform send short Message class