用户
 找回密码
 入住 CI 中国社区
搜索
查看: 915|回复: 2
收起左侧

[版本 3.x] CI用XML-PRC收不到200返回信息

[复制链接]
发表于 2016-3-30 11:28:27 | 显示全部楼层 |阅读模式
CI版本3.0.6
Did not receive a '200 OK' response from remote server. (HTTP/1.1 404 Not Found)

客户Xmlrpc_client.php
PHP复制代码
 
<?php
 
class Xmlrpc_client extends CI_Controller {
 
    public function index()
    {
        $this->load->helper('url');
        $server_url = site_url('xmlrpc_server');
 
        $this->load->library('xmlrpc');
 
        $this->xmlrpc->server($server_url, 80);
        $this->xmlrpc->method('Greetings');
 
        $request = array('How is it going?');
        $this->xmlrpc->request($request);
 
        if ( ! $this->xmlrpc->send_request())
        {
            echo $this->xmlrpc->display_error();
        }
        else
        {
            echo '<pre>';
            print_r($this->xmlrpc->display_response());
            echo '</pre>';
        }
    }
}
?>
 
 
复制代码



服务器端Xmlrpc_server.php
PHP复制代码
 
<?php
class Xmlrpc_server extends CI_Controller {
 
    public function index()
    {
        $this->load->library('xmlrpc');
        $this->load->library('xmlrpcs');
 
        $config['functions']['Greetings'] = array('function' => 'Xmlrpc_server.process');
 
        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();
    }
 
 
    public function process($request)
    {
        $parameters = $request->output_parameters();
 
        $response = array(
            array(
                'you_said'  => $parameters[0],
                'i_respond' => 'Not bad at all.'
            ),
            'struct'
        );
 
        return $this->xmlrpc->send_response($response);
    }
}
 
复制代码




 楼主| 发表于 2016-3-31 12:00:38 | 显示全部楼层
找到原因了,路径请求有问题。
修改了config['base_url']中的值
$server_url = site_url('xmlrpc_server');
发表于 2016-4-1 14:44:34 | 显示全部楼层
nasaplayer 发表于 2016-3-31 12:00
找到原因了,路径请求有问题。
修改了config['base_url']中的值
$server_url = site_url('xmlrpc_server') ...

base_url 这个在 CI 3 里必须设置。

本版积分规则