"PHP" Gen Blue 253 Cloud Communication Platform International SMS Interface Call demo case

Source: Internet
Author: User

PHP Interface Request Class
<?php
Header ("content-type:text/html; Charset=utf-8 ");

/

    • Class Name: Chuanglansmsapi
    • Function: Create blue Interface Request Class
    • Details: Constructs the blue text message interface request, obtains the remote HTTP data
    • Version: 1.3
    • Date: 2017-04-12
    • Description
    • The following code is only for the convenience of customer testing and provide the sample code, customers can according to the needs of their own website, according to the technical documentation, not a
      Be sure to use this code.
    • This code is only for learning and research on the blue interface used, just to provide a reference.
      */

Class Chuanglansmsapi {

Interface URL used to send Smsconst api_send_url= ' Http://intapi.253.com/send/json? '; /interface URL used to Query SMS balanceconst api_balance_query_url= ' Http://intapi.253.com/balance/json? ';   Const api_account= ';//get SMS account from https://zz.253.com/site/login.html const api_password= ';//get SMS PASSWORD From https://zz.253.com/site/login.html/** * Send SMS * * @param string $mobile phone number * @param string $msg text message inside Capacitive */public function sendinternational ($mobile, $msg) {//Create Blue interface parameter $POSTARR = Array (' account ' = = self::a    Pi_account, ' Password ' and Self::api_password, ' msg ' = $msg, ' mobile ' and ' $mobile ');    $result = $this->curlpost (self::api_send_url, $POSTARR); return $result;} /** * Query Amount * * Query address */public function querybalance () {//query parameter $POSTARR = Array (' account ' = = Self::api_    Account, ' password ' = Self::api_password,); $result = $this->curlpost (Self::api_balance_query_url, $POSTARR); return $result;} /** * Send HTTP request via Curl * @param string $url//Request URL * @param array $postFields//Request parameter * @return mixed */private function C    Urlpost ($url, $postFields) {$postFields = Json_encode ($postFields);    $ch = Curl_init ();     curl_setopt ($ch, Curlopt_url, $url);    curl_setopt ($ch, Curlopt_httpheader, Array (' Content-type:application/json; Charset=utf-8 '));    curl_setopt ($ch, Curlopt_returntransfer, 1);    curl_setopt ($ch, Curlopt_post, 1);    curl_setopt ($ch, Curlopt_postfields, $postFields);     curl_setopt ($ch, curlopt_timeout,1);    curl_setopt ($ch, curlopt_ssl_verifyhost, 0);    curl_setopt ($ch, Curlopt_ssl_verifypeer, 0);    $ret = curl_exec ($ch);    if (false = = $ret) {$result = Curl_error ($ch);        } else {$rsp = Curl_getinfo ($ch, Curlinfo_http_code); if (!== $rsp) {$result = "request Status". $rsp. " " .        Curl_error ($ch);        } else {$result = $ret; }} Curl_cLose ($ch); return $result;}

}

"PHP" Gen Blue 253 Cloud Communication Platform International SMS Interface Call demo case

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.