0

我在将参数值从 xmlrpc 服务器传递到使用 cron 作业递归调用的控制器方法时遇到问题。我的 xml rpc 服务器方法:

function update_p($request) {
        $parameters = $request->output_parameters();

        $_GET["portfolio"] = $parameters['0']["portfolio"];
        $_GET["filter"] = $parameters['0']["filter"];
        $_GET["sort"] = $parameters['0']["sort"];
        $_GET["first"] = $parameters['0']["first"];
        $_GET["watch"] = $parameters['0']["watch"];
        redirect("controllerClass/update_p");

        return 1;
    }

我的控制器类带有我想向其传递所有这些参数组合、过滤器等的方法:

公共函数 update_p() { $loginid = $this->session->userdata('loginid'); 如果(!isset($loginid)){死;}

    error_reporting(E_ERROR);
    if (time()>$this->session->userdata('expire'))

{ redirect("/dashboard/logout?expired=Y","location",401); 死; }

    $out='';

    $request="USER ".$loginid.($this->session->userdata('isMobile')?"@mobile":"")."\n";

    if(isset($_GET["portfolio"])) {
        $portfolio=trim($_GET["portfolio"]);
        $request.='ECHO "LISTP":'."\nLISTP0 #".$portfolio;
        if(isset($_GET["filter"])) {
            $filter=trim($_GET["filter"]);
            $request.=" -".$filter;
        }
        if(isset($_GET["sort"])) {
            $sort=trim($_GET["sort"]);
            if ($sort>=1024) $request.=" -s".($sort&1023);
            else $request.=" -S".$sort;
        }
        $ph = isset($_GET["first"]);
        if ($ph) { 
            $this->load->model('modelmethod');
            $resultArray = $this->modelmethod->getData($this->session->userdata('loginid'),$this->session->userdata('isMobile')?'mobile':'default','listp');
            $request.=" ".$resultArray[0]['listp'];
        }
        $request.="\nECHO ,\n";
        if(isset($_GET["watch"])) {
            $portfolio=trim($_GET["watch"]);
            if ($ph)
                $resultArray = $this->modelmethod->getData($this->session->userdata('loginid'),$this->session->userdata('isMobile')?'mobile':'default','watch');
            $request.='ECHO "watchl":'."\nLISTP1 #".$portfolio." -WL ".($ph?$resultArray[0]['watch']:"")."\n";
            $request.='ECHO ,"watchs":'."\nLISTP1 #".$portfolio." -WS\nECHO ,\n";
        }
    }
    $request.="RISk\nECHO ,\nPnL\n";

    if ($result=$this->getData($request."BYE\n")) {
        if (result!='') $out=$result."\n";
    }

    ob_start('ob_gzhandler');
    echo "{".$out."}";
    ob_end_flush();

}

我正在尝试使用 firbug 控制台使用以下代码对其进行测试:

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://example/api/v1/update_p?");
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("portfolio=0&filter=A&sort=1&first=Y");

任何帮助将不胜感激谢谢。

4

1 回答 1

0

希望它有所帮助:
编辑1:

function update_p($request) {
    $parameters = $request->output_parameters();

    $_GET["portfolio"] = $parameters['0']["portfolio"];
    $_GET["filter"] = $parameters['0']["filter"];
    $_GET["sort"] = $parameters['0']["sort"];
    $_GET["first"] = $parameters['0']["first"];
    $_GET["watch"] = $parameters['0']["watch"];
    //redirect("controllerClass/update_p/".$_GET["portfolio"].'/'.$_GET["filter"].'/'.$_GET["sort"].'/'.$_GET["first"].'/'.$_GET["watch"], 'refresh');
    $url   = base_url("controllerClass/update_p/".$_GET["portfolio"].'/'.$_GET["filter"].'/'.$_GET["sort"].'/'.$_GET["first"].'/'.$_GET["watch"]);
    header("Location: $url");

    return 1;
}

控制器方法

function update_p(){
    $portfolio  = $this->uri->segment(3);
    $filter     = $this->uri->segment(4);
    $sort       = $this->uri->segment(5);
    $first      = $this->uri->segment(6);
    $watch      = $this->uri->segment(7);
}
于 2013-09-11T08:34:07.333 回答