简体   繁体   English

我在使用json codeigniter时遇到问题,请注意其未关闭标签

[英]i am having a issue with json codeigniter rest its not closing the tag

i am having a problem with json codeigniter rest 我在json codeigniter rest遇到问题

i am making this call to the server and the problem its that its not closing the json tags 我正在对服务器进行此调用,问题是它没有关闭json标签

s, USA","clientUID":"7","email":null,"idipad":"2","dateModified":null},{"id":"19","uid":null,"name":"Wayne Corporation, Inc.","phone":"932345324","address":"Second st. s,USA“,” clientUID“:” 7“,” email“:null,” idipad“:” 2“,” dateModified“:null},{” id“:” 19“,” uid“:null,”名称”:“ Wayne Corporation,Inc.”,“电话”:“ 932345324”,“地址”:“第二街 312, Gotham City","clientUID":"7","email":"waynecorp@gmail.com","idipad":"1","dateModified":null}] 312,哥谭市”,“ clientUID”:“ 7”,“电子邮件”:“ waynecorp@gmail.com”,“ idipad”:“ 1”,“ dateModified”:null}]

its missing the final } 它缺少最后一个}

this is the code that creates the response : 这是创建响应的代码:

$this->response(array('login'=>'login success!','user_admin_id'=>$user_id,'client'=>$client,'users'=>$users,'projects'=>$projects,'plans'=>$plans,'meetings'=>$meetings,'demands'=>$demands,'tasks'=>$tasks,'presences'=>$presences,'contractors'=>$contractors,'companies'=>$companies), 200);

this is the client call using curl : 这是使用curl的客户端调用:

$this->curl->create(' http://dev.onplans.ch/onplans/index.php/api/example/login/format/json '); $ this-> curl-> create(' http://dev.onplans.ch/onplans/index.php/api/example/login/format/json ');

// Option & Options
$this->curl->option(CURLOPT_BUFFERSIZE, 10);
$this->curl->options(array(CURLOPT_BUFFERSIZE => 10));

// More human looking options
$this->curl->option('buffersize', 10);

// Login to HTTP user authentication
$this->curl->http_login('admin', '1234');

// Post - If you do not use post, it will just run a GET request
//$post = array('remember'=>'true','email'=>'admin.architect@onplans.ch','password'=>'password');
        $post = array('remember'=>'true','email'=>'admin.architect@onplans.ch','password'=>'password');
$this->curl->post($post);

// Cookies - If you do not use post, it will just run a GET request
$vars = array('remember'=>'true','email'=>'manuel@ffff.com','password'=>'password');
$this->curl->set_cookies($vars);

// Proxy - Request the page through a proxy server
// Port is optional, defaults to 80
//$this->curl->proxy('http://example.com', 1080);
//$this->curl->proxy('http://example.com');

// Proxy login
//$this->curl->proxy_login('username', 'password');

// Execute - returns responce
echo $this->curl->execute();

// Debug data ------------------------------------------------

// Errors
$this->curl->error_code; // int
$this->curl->error_string;


        print_r('error :::::LOGINN REMOTE:::::'.$this->curl->error_string);
// Information
$this->curl->info; // array

       print_r('info :::::::::::::'.$this->curl->info);

the response belong to the rest api codeigniter from phil 响应属于phil的其余api codeigniter

/**
 * Response
 *
 * Takes pure data and optionally a status code, then creates the response.
 *
 * @param array $data
 * @param null|int $http_code
 */
public function response($data = array(), $http_code = null)
{
    global $CFG;

    // If data is empty and not code provide, error and bail
    if (empty($data) && $http_code === null)
    {
        $http_code = 404;

        // create the output variable here in the case of $this->response(array());
        $output = NULL;
    }

    // If data is empty but http code provided, keep the output empty
    else if (empty($data) && is_numeric($http_code))
    {
        $output = NULL;
    }

    // Otherwise (if no data but 200 provided) or some data, carry on camping!
    else
    {
        // Is compression requested?
        if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE)
        {
            if (extension_loaded('zlib'))
            {
                if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
                {
                    ob_start('ob_gzhandler');
                }
            }
        }

        is_numeric($http_code) OR $http_code = 200;

        // If the format method exists, call and return the output in that format
        if (method_exists($this, '_format_'.$this->response->format))
        {
            // Set the correct format header
            header('Content-Type: '.$this->_supported_formats[$this->response->format]);

            $output = $this->{'_format_'.$this->response->format}($data);
        }

        // If the format method exists, call and return the output in that format
        elseif (method_exists($this->format, 'to_'.$this->response->format))
        {
            // Set the correct format header
            header('Content-Type: '.$this->_supported_formats[$this->response->format]);

            $output = $this->format->factory($data)->{'to_'.$this->response->format}();
        }

        // Format not supported, output directly
        else
        {
            $output = $data;
        }
    }

    header('HTTP/1.1: ' . $http_code);
    header('Status: ' . $http_code);

    // If zlib.output_compression is enabled it will compress the output,
    // but it will not modify the content-length header to compensate for
    // the reduction, causing the browser to hang waiting for more data.
    // We'll just skip content-length in those cases.
    if ( ! $this->_zlib_oc && ! $CFG->item('compress_output'))
    {
        header('Content-Length: ' . strlen($output));
    }

    exit($output);
}

This answer was referenced from Github issue . Github问题引用了此答案。 Also raised by Pedro Dinis, i guest. 我也是Pedro Dinis提出的。 I met this problem today and take me long hours to search for the solution. 我今天遇到了这个问题,花了很长时间寻找解决方案。 I share here with hope to help someone like me. 我在这里分享,希望能帮助像我这样的人。 The key is to replace around line 430 in the library file: REST_Controller.php : 关键是替换库文件REST_Controller.php中的第430行:

header('Content-Length: ' . strlen($output));

by 通过

header('Content-Length: ' . strlen("'".$output."'"));

UPDATE: The problem was solved here Or you can just comment out the code, it will run fine. 更新:问题已在此处解决,或者您可以将代码注释掉,它将正常运行。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 codeigniter:Rest API + Json - codeigniter: Rest api + Json 我在改造 android 中使用 Login Api 时遇到问题 - I am having issue to consume Login Api in retrofit android Codeigniter Rest API路由问题 - Codeigniter rest api route issue 为什么我会收到 JSON 反序列化错误和 REST API? - Why am I getting a JSON deserializing error with a REST API? 我在设计 REST api 调用时遇到问题,使用请求访问 Kinetica 数据库实例以确认它正在工作 - I am having trouble designing a REST api call using requests to hit a Kinetica DB instance to confirm it is working 我无法将嵌套的 json 转换为 dataframe。 我从 API 得到 json 并希望它在 dataframe - I am having trouble converting my nested json into a dataframe. I am getting the json from an API and want it in a dataframe 我正在尝试从 newsapi.org 获取数据但遇到问题 - I am trying to fetch data from newsapi.org but having issue Codeigniter REST API中缺少最后几个字符,json Response - Last few characters missing in Codeigniter REST API, json Response 使用Phil Sturgeon的REST服务器,PHP,Codeigniter进行奇怪的JSON输出 - Strange JSON output with Phil Sturgeon's REST Server, PHP, Codeigniter 我遇到了 CORS 问题吗? - Am I running into a CORS issue?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM