问题是使用php和外部类

时间:2016-03-07 11:54:05

标签: php soap

我想为注册用户发送短信。

我的sms getway提供程序使用SOAP将用户连接到api。

这就是代码的工作原理:

function sendSMS($mobile, $text){
    ini_set("soap.wsdl_cache_enabled", "0");
    $value = array('MY USER', 'My pass', 'my sms server number', user mobile number, $text, '1');
    $url = 'http://mysmsmprovider.com/WebService/V4/BoxService.asmx?wsdl';
    $method = 'SendMessage';
    $param = array('Username' => "$value[0]",'Password' => "$value[1]",'Number' => "$value[2]",'Mobile' => array("$value[3]"),'Message' => "$value[4]",'Type' => "$value[5]");
    define($security,1);
    require_once ("connection.php");
    $request = new connection($url,$method,$param);
    $message = $request->connect();
    $request->__destruct();
    unset($value,$url,$method,$param,$request);
    if ($message == 'Send Successfully'){
        return 1;
    }else{
        return 0;
    }
}

现在是connection.php文件内容:

<?php
if(!defined($security)){
    header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
    die();
}
class connection{
    public $value;
    public $method;
    public $url;
    public $type;
    function __construct($url,$method,$value,$type=''){
        $this->value = $value;
        $this->method = $method;
        $this->url = $url;
        $this->type = $type;
    }
    function connect(){
        ini_set("soap.wsdl_cache_enabled", "0");
        $client = new SoapClient($this->url);
        $result = $client->__SoapCall($this->method, array($this->value));
        if($this->type == 'object')
            return get_object_vars($result);
        $merge = $this->method.'Result';
        if($result->$merge->string != '')
            return $result->$merge->string;
        else
            return $result->$merge;
    }
    function __destruct(){
        unset($this->value,$this->url,$this->method,$this->type);
    }
}
?>

但是当我想在顶部使用功能时我不能!你用android发出请求,我100%确定android部分是如此优秀和好。

问题是php。

我无法在另一个php类或php文件中使用此代码发送短信。但是之前我用过相同的代码!

你的建议是什么意思?

0 个答案:

没有答案