"PHP" Gen Blue 253 Cloud communication PAAs platform SMS Verification Code Interface call Demo

Source: Internet
Author: User

<?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-&Gt;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

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.