| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx

PHP短信验证码接口调用demo

0
PHP C/C++ Go 接口调用 3855 次浏览

 

基于创蓝253云通讯平台的PHP短信验证码接口调用demo:

 

<?php
header("Content-type:text/html; charset=UTF-8");



class ChuanglanSmsApi {

        //发送短信的接口地址
        const API_SEND_URL='http://sms.253.com/msg/send?';

        //查询余额的接口地址
        const API_BALANCE_QUERY_URL='http://sms.253.com/msg/balance?';

        const API_ACCOUNT='*******';//短信账号从 https://zz.253.com/site/login.html 里面获取。

        const API_PASSWORD='*******';//短信密码从 from https://zz.253.com/site/login.html 里面获取。

        /**
         * 发送短信需要的接口参数
         *
         * @param string $mobile                 手机号码
         * @param string $msg                         想要发送的短信内容
         * @param string $needstatus         是否需要状态报告 '1'为需要 '0'位不需要。
         */
        public function sendSMS( $mobile, $msg, $needstatus = 1) {
                
                //发送短信的接口参数
                $postArr = array (
                                          'un' => self::API_ACCOUNT,
                                          'pw' => self::API_PASSWORD,
                                          'msg' => $msg,
                                          'phone' => $mobile,
                                          'rd' => $needstatus
                     );
                
                $result = $this->curlPost( self::API_SEND_URL , $postArr);
                return $result;
        }
        
        /**
         * 
         *
         *  查询余额
         */
        public function queryBalance() {
                
                // 查询接口参数
                $postArr = array ( 
                          'un' => self::API_ACCOUNT,
                          'pw' => self::API_PASSWORD,
                );
                $result = $this->curlPost(self::API_BALANCE_QUERY_URL, $postArr);
                return $result;
        }

        /**
         * 处理接口返回值
         * 
         */
        public function execResult($result){
                $result=preg_split("/[,\r\n]/",$result);
                return $result;
        }

        /**
         * @param string $url  
         * @param array $postFields 
         * @return mixed
         */
        private function curlPost($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;
        }
        
        //魔术获取
        public function __get($name){
                return $this->$name;
        }
        
        //魔术设置
        public function __set($name,$value){
                $this->$name=$value;
        }
}
?>
 

70个答案

0
0

ฝาก30รับ100  Latest 2021 Promotion Hits Slots Can play all game camps, new members, deposit 30, get 100, give away free credit, no need to deposit, no need to share Promotion deposit 30 get 100 unlimited withdrawal No minimum deposit

0

ฝาก10รับ100 is a promotion, online slots, deposit 10, get 100 new Popular for people with small capital, really suitable for investors. With a small budget to play, Web Slots 10 Get 100 is a game that is very popular right now.

0

19รับ100 Slot deposit 19 get the latest 100 2021 is a new pro slot and the strongest of the year Appealing to slot spinners with low budget who want to take money 19 baht to exchange money in the amount of 100 baht, which is considered very worthwhile because the promotion deposit 19 receives 100 unlimited withdrawals

0

ฝาก20รับ100 A promotion that many people like and think that it is a worthwhile promotion.

0

โรม่า  Roma, the most popular online slots game of all time, roma slot 888, play free, online roma slot games. playing for real money Legendary online gambling game 2021 Roma Slots from famous gaming companies

0

Roma  Roma slot, the most popular online slot game of all time, roma slot 888, play free, online roma slot game. playing for real money Legendary online gambling game 2021 Roma Slots from famous gaming companies

0

50รับ150 Deposit 50, get 150, no need to turn or call it easy to understand is a promotion, deposit 50, get 150 wallet as another

0

slot currently has online slot games. Comes in a new format with 3D images as slots online, direct websites and leading game camps such as PG SLOT JOKER GAME, new member registration, 100% bonus and many more slots

0

เครดิตฟรี  currently has online slot games. Comes in a new format with 3D images as slots online, direct websites and leading game camps such as PG SLOT JOKER GAME, new member registration, 100% bonus and many more slots

0

PG   The latest with a game system designed for direct pg slot players because the game format is very advanced, can play pg slot auto via ios and android systems, supports playing pg slots via mobile Deposit-withdraw automatically in just 8 seconds

0

เล่นสล็อต Free Trial PG and Joker is to play slots for free without having to pay a deposit first. There are currently playing slots. mostly through the mobile internet without having to go to the casino to play slots

0

Betflix  currently has online slot games. Comes in a new format with 3D images as slots online, direct websites and leading game camps such as PG SLOT JOKER GAME, new member registration, 100% bonus and many more slots

0

joker game online slot games The most popular of the year 2021, joker game, deposit-withdraw, no minimum, there is a popular game like roma slot, apply for a joker game today, get a 100% bonus if you ask about the hot online gambling game overtaking the curve.

0

PG  The latest with a game system designed for direct pg slot players because the game format is very advanced, can play pg slot auto via ios and android systems, supports playing pg slots via mobile Deposit-withdraw automatically in just 8 seconds

0

ทดลองเล่นสล็อต

Slots Free Trial Playable Withdrawable Free Trial Playable Withdraw Real Money Free credit to play slots Terms and conditions are as specified by the website.

0

Joker gamedirect online slots Not through a joker agent, deposit-withdraw, no minimum, quality online gambling website that receives international standards, joker slots, easy to play, get real money.

0

เครดิตฟรี  Latest free credit 2021 online gambling website latest free credit All in one website, free credit, PG, slot promotions. Free credit, no deposit, no sharing

0

slot  We have included all web slots camps. already here The best new online slots website of the year 2021, the only website to play slots for all game camps. From leading camps across the country, including pg slot, joker game, slotxo, live22 and many others

0

สล็อต789  Online slots no minimum deposit-withdrawal with automation As fast as 8 seconds, including online slots from leading slot game camps

1 2 3 4