Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php can';如果在我的服务器上不使用file(),我必须使用cURL,那么如何使这个庞大的SMS代码工作呢?_Php - Fatal编程技术网

Php can';如果在我的服务器上不使用file(),我必须使用cURL,那么如何使这个庞大的SMS代码工作呢?

Php can';如果在我的服务器上不使用file(),我必须使用cURL,那么如何使这个庞大的SMS代码工作呢?,php,Php,不能在我的服务器上使用file(),我必须使用cURL,如何使这段代码工作?无法使用文件();在我的服务器上,因为allow_urlopen()已关闭,所以可以使用哪个cURL函数来代替file(); 这是一个批量sms api <?php //Check if sms notification is enabled if(isset($configInfo['sms_note']) AND $configInfo['sms_note'

不能在我的服务器上使用file(),我必须使用cURL,如何使这段代码工作?无法使用文件();在我的服务器上,因为allow_urlopen()已关闭,所以可以使用哪个cURL函数来代替file(); 这是一个批量sms api

<?php 
    //Check if sms notification is enabled

        if(isset($configInfo['sms_note']) 
            AND $configInfo['sms_note'] == 'Enabled'){

            $newPhone = str_replace('+', '', $phone);
            $SMSCode = $SMSCode;
            $SMSsender = $configInfo['sms_sender'];
            $SMSport = $configInfo['sms_port'];
            $SMSurl = $configInfo['sms_gateway_url'];
            $SMSusername = $configInfo['sms_gateway_user'];
            $SMSpassword = $configInfo['sms_gateway_pass'];
            $SMSsitename = $siteInfo['site_name'];

        class Sender {
            var $host;
            var $port;
            var $strUserName;
            var $strPassword;
            var $strSender;
            var $strMessage;
            var $strMobile;
            var $strMessageType;
            var $strDlr;
            var $phoneCode;
            var $newPhone;
            var $SMSCode;
            var $SMSsender;
            var $SMSport;
            var $SMSusername;
            var $SMSpassword;
            var $SMSsitename;
            var $senderName;

            private function sms__unicode($message) {
                $hex1 = '';
                if (function_exists('iconv')) {
                    $latin = @iconv('UTF-8', 'ISO-8859-1', $message);
                    if (strcmp($latin, $message)) {
                        $arr = unpack('H*hex', @iconv('UTF-8', 'UCS-2BE',$message));
                        $hex1 = strtoupper($arr['hex']);
                    }
                    if ($hex1 == '') {
                        $hex2 = '';
                        $hex = '';
                        for ($i = 0; $i < strlen($message); $i++) {
                            $hex = dechex(ord($message[$i]));
                            $len = strlen($hex);
                            $add = 4 - $len;
                            if ($len < 4) {
                                for ($j = 0; $j < $add; $j++) {
                                    $hex = "0" . $hex;
                                }
                            }
                            $hex2.=$hex;
                        }
                        return $hex2;
                    } else {
                        return $hex1;
                    }
                } else {
                    print 'iconv Function Not Exists !';
                }
            }

            //Constructor.. 
            public function Sender($host, $port, $username, $password, $sender, $message, $mobile, $msgtype, $dlr) {
                global $phoneCode;
                global $newPhone;
                global $SMSCode;
                global $SMSsender;
                global $SMSport;
                global $SMSurl;
                global $SMSusername;
                global $SMSpassword;
                global $SMSsitename;
                $this->host = $SMSurl;
                $this->port = $SMSport;
                $this->strUserName = $SMSusername;
                $this->strPassword = $SMSpassword;
                $this->strSender = $SMSsender;
                $this->strMessage = $SMSsitename." Phone Verification Code: ".$SMSCode.". Thanks";
                $this->strMobile = $newPhone;
                $this->strMessageType = 0;
                $this->strDlr = 0;
            }

            public function Submit() {
                $port = "";
                if($this->port == '') {
                    $port = ":" . $this->port;
                }
                if ($this->strMessageType == "2" || $this->strMessageType == "6") {
                    //Call The Function Of String To HEX. 
                    $this->strMessage = $this->sms__unicode($this->strMessage);
                    try {
                        //Smpp http Url to send sms.
                        $live_url = "http://" . $this->host . ":" . $this->port . "/bulksms/bulksms?username=" . $this->strUserName . "&password=" . $this->strPassword . "&type=" . $this->strMessageType . "&dlr=" . $this->strDlr . "&destination=" . $this->strMobile . "&source=" . $this->strSender . "&message=" . $this->strMessage . "";
                        $parse_url = file($live_url):
                        echo $parse_url[0];
                    } catch (Exception $e) {
                        echo 'Message:' . $e->getMessage();
                    }
                } else {
                    $this->strMessage = urlencode($this->strMessage);
                    try {
                        //Smpp http Url to send sms.
                        $live_url = "http://" . $this->host . ":" . $this->port. "/bulksms/bulksms?username=" . $this->strUserName . "&password=" . $this->strPassword . "&type=" . $this->strMessageType . "&dlr=" . $this->strDlr . "&destination=" . $this->strMobile . "&source=" . $this->strSender . "&message=" . $this->strMessage . "";
                        $parse_url = file($live_url);
                       echo $parse_url[0];



                    } catch (Exception $e) {
                        echo 'Message:' . $e->getMessage();
                    }
                }
            }
        } 

        //Call The Constructor. 
        $obj = new Sender("IP/DOMAIN","PORT","USERNAME","PASSWORD","SENDER/SOURCE","MESSAGE","DESTINATION","MESSAGE TYPE","1");
        $obj->Submit ();





    }


    ?>
    <?php 
    //Check if sms notification is enabled

        if(isset($configInfo['sms_note']) 
            AND $configInfo['sms_note'] == 'Enabled'){

            $newPhone = str_replace('+', '', $phone);
            $SMSCode = $SMSCode;
            $SMSsender = $configInfo['sms_sender'];
            $SMSport = $configInfo['sms_port'];
            $SMSurl = $configInfo['sms_gateway_url'];
            $SMSusername = $configInfo['sms_gateway_user'];
            $SMSpassword = $configInfo['sms_gateway_pass'];
            $SMSsitename = $siteInfo['site_name'];

        class Sender {
            var $host;
            var $port;
            var $strUserName;
            var $strPassword;
            var $strSender;
            var $strMessage;
            var $strMobile;
            var $strMessageType;
            var $strDlr;
            var $phoneCode;
            var $newPhone;
            var $SMSCode;
            var $SMSsender;
            var $SMSport;
            var $SMSusername;
            var $SMSpassword;
            var $SMSsitename;
            var $senderName;

            private function sms__unicode($message) {
                $hex1 = '';
                if (function_exists('iconv')) {
                    $latin = @iconv('UTF-8', 'ISO-8859-1', $message);
                    if (strcmp($latin, $message)) {
                        $arr = unpack('H*hex', @iconv('UTF-8', 'UCS-2BE',$message));
                        $hex1 = strtoupper($arr['hex']);
                    }
                    if ($hex1 == '') {
                        $hex2 = '';
                        $hex = '';
                        for ($i = 0; $i < strlen($message); $i++) {
                            $hex = dechex(ord($message[$i]));
                            $len = strlen($hex);
                            $add = 4 - $len;
                            if ($len < 4) {
                                for ($j = 0; $j < $add; $j++) {
                                    $hex = "0" . $hex;
                                }
                            }
                            $hex2.=$hex;
                        }
                        return $hex2;
                    } else {
                        return $hex1;
                    }
                } else {
                    print 'iconv Function Not Exists !';
                }
            }

            //Constructor.. 
            public function Sender($host, $port, $username, $password, $sender, $message, $mobile, $msgtype, $dlr) {
                global $phoneCode;
                global $newPhone;
                global $SMSCode;
                global $SMSsender;
                global $SMSport;
                global $SMSurl;
                global $SMSusername;
                global $SMSpassword;
                global $SMSsitename;
                $this->host = $SMSurl;
                $this->port = $SMSport;
                $this->strUserName = $SMSusername;
                $this->strPassword = $SMSpassword;
                $this->strSender = $SMSsender;
                $this->strMessage = $SMSsitename." Phone Verification Code: ".$SMSCode.". Thanks";
                $this->strMobile = $newPhone;
                $this->strMessageType = 0;
                $this->strDlr = 0;
            }

            public function Submit() {
                $port = "";
                if($this->port == '') {
                    $port = ":" . $this->port;
                }
                if ($this->strMessageType == "2" || $this->strMessageType == "6") {
                    //Call The Function Of String To HEX. 
                    $this->strMessage = $this->sms__unicode($this->strMessage);
                    try {
                        //Smpp http Url to send sms.
                        $live_url = "http://" . $this->host . ":" . $this->port . "/bulksms/bulksms?username=" . $this->strUserName . "&password=" . $this->strPassword . "&type=" . $this->strMessageType . "&dlr=" . $this->strDlr . "&destination=" . $this->strMobile . "&source=" . $this->strSender . "&message=" . $this->strMessage . "";
                        $parse_url = file($live_url):
                        echo $parse_url[0];
                    } catch (Exception $e) {
                        echo 'Message:' . $e->getMessage();
                    }
                } else {
                    $this->strMessage = urlencode($this->strMessage);
                    try {
                        //Smpp http Url to send sms.
                        $live_url = "http://" . $this->host . ":" . $this->port. "/bulksms/bulksms?username=" . $this->strUserName . "&password=" . $this->strPassword . "&type=" . $this->strMessageType . "&dlr=" . $this->strDlr . "&destination=" . $this->strMobile . "&source=" . $this->strSender . "&message=" . $this->strMessage . "";
                        $parse_url = file($live_url);
                       echo $parse_url[0];



                    } catch (Exception $e) {
                        echo 'Message:' . $e->getMessage();
                    }
                }
            }
        } 

        //Call The Constructor. 
        $obj = new Sender("IP/DOMAIN","PORT","USERNAME","PASSWORD","SENDER/SOURCE","MESSAGE","DESTINATION","MESSAGE TYPE","1");
        $obj->Submit ();





    }


    ?>

我认为你应该使用文件内容而不是文件。从代码中可以看出,您只关心内容

您的
发送方
构造函数需要编辑,因此它实际上正在使用参数。现在它得到了虚拟值