<?php
Header ("content-type:text/html; Charset=utf-8 ");
Class Chuanglansmsapi {
Send SMS Interface Address const api_send_url= ' http://sms.253.com/msg/send? '; Query the balance of the interface address const api_balance_query_url= ' http://sms.253.com/msg/balance? '; Const api_account= ' ******* ';//SMS account is obtained from https://zz.253.com/site/login.html. Const api_password= ' ******* ';//SMS password is obtained from https://zz.253.com/site/login.html. /** * Interface parameters required to send SMS * * @param string $mobile phone number * @param string $msg The text message you want to send * @param string $needstatus Whether the status report required ' 1 ' is required for ' 0 ' bit. */Public Function sendsms ($mobile, $msg, $needstatus = 1) {//interface parameter for sending SMS $POSTARR = Array ( ' UN ' = self::api_account, ' pw ' = self::api_p Assword, ' msg ' = $msg, ' phone ' and ' = ' $mobile , ' rd ' = $needstatus); $result = $this-≫curlpost (Self::api_send_url, $POSTARR); return $result; }/** * * * Query Balance * * Public Function querybalance () {//query interface parameter $POSTARR = AR Ray (' un ' = self::api_account, ' pw ' = Self::api_password,) ; $result = $this->curlpost (self::api_balance_query_url, $POSTARR); return $result; /** * * * * Processing interface return value * */Public Function Execresult ($result) {$result =preg_split ("/[,\r\n]/", $re Sult); return $result; }/** * @param string $url * @param array $postFields * @return mixed */Private function Curlpos T ($url, $postFields) {$postFields = Http_build_query ($postFields); if (function_exists (' Curl_init ')) {$ch = Curl_init (); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_postfields, $postFields); $result = curl_exec ($ch); if (Curl_errno ($ch)) {return ' Curl Error: '. Curl_error ($ch); } curl_close ($ch); }elseif (function_exists (' file_get_contents ')) {$result =file_get_contents ($url. $postFields); } return $result; }//Magic get Public Function __get ($name) {return $this, $name; }//Magic set Public Function __set ($name, $value) {$this, $name = $value; }
}
?>
"PHP" Gen Blue 253 Cloud communication PAAs platform SMS Verification Code Interface call Demo