Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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方法中访问REST delete请求传递的参数_Php_Codeigniter_Rest - Fatal编程技术网

在PHP方法中访问REST delete请求传递的参数

在PHP方法中访问REST delete请求传递的参数,php,codeigniter,rest,Php,Codeigniter,Rest,我正在使用codeigniter开发一些RESTful服务。我有一个基本控制器,它根据HTTP请求(GET、POST、DELETE、PUT)在子控制器中调用不同的方法。下面是子控制器的代码 class Example extends REST_Controller { private $username; private $password; private $ti

我正在使用codeigniter开发一些RESTful服务。我有一个基本控制器,它根据HTTP请求(GET、POST、DELETE、PUT)在子控制器中调用不同的方法。下面是子控制器的代码

     class Example extends REST_Controller
            {
                private $username;
                private $password;

                private $time_format;
                private $date_format;

                private $tz;
                private $tz_utc;

                private $prefs;

                function __construct() {
                    parent::__construct();
                    // mod_php
                    if ($this->input->server('PHP_AUTH_USER'))
                    {
                        $this->username = $this->input->server('PHP_AUTH_USER');
                        $this->password = $this->input->server('PHP_AUTH_PW');
                    }

                    // most other servers
                    elseif ($this->input->server('HTTP_AUTHENTICATION'))
                    {
                        if (strpos(strtolower($this->input->server('HTTP_AUTHENTICATION')), 'basic') === 0)
                        {
                            list($this->username, $this->password) = explode(':',     base64_decode(substr($this->input->server('HTTP_AUTHORIZATION'), 6)));
                        }
                    }
                    // FIXME: Does this case appear ? We are already validating in Parent class
                    // @see REST_Controller:220,213
                    if ( $this->username == null || $this->password == null) {
                        $this->output->set_output(json_encode(' Unauthorized access '));
                    }

                    $this->date_format = $this->dates->date_format_string('date');
                    $this->time_format = $this->dates->time_format_string('date');

                    $this->tz = $this->timezonemanager->getTz(
                                    $this->config->item('default_timezone'));
                    $this->tz_utc = $this->timezonemanager->getTz('UTC');
                    // we are not loading any user preferences
                    //$this->prefs =
                    //Preferences::singleton($this->session->userdata('prefs'));

                    $this->load->library('caldav');

                    $this->output->set_content_type('application/json');
                }

                /**
                 *  Fetches all calendars of logged in user
                 */
                function allcalendar_get()
                {
                    $arr_calendars = $this->caldav->all_user_calendars(
                                    $this->username,
                                    $this->password);
                    $this->output->set_output(json_encode($arr_calendars));
                }
                /**
                 * Creates a calendar
                 */
                function newcalendar_post()
                {

                    // Get current own calendars
                    $current_calendars = $this->caldav->get_own_calendars(
                                    $this->username,
                                    $this->password
                    );
                }
                // deletes a resource
                function event_delete() {
                    if (!$this->get('href'))
                    {  // response is 400 eventhough I pass href in url like below
                       // http://localhost/app/index.php/example/event?href=89290E
                       $this->response(NULL, 400);
                    }
                }
   } 

我正在尝试使用$this->get('href')访问事件_delete方法中url中传递的href参数,但传递的值为空。请建议我传递参数以删除REST调用的更好方法。

显示
get()
方法的代码。另外,这样构造URL不是更好吗:
http://localhost/app/index.php/example/event/89290E
只需执行
$this->uri->segment(3)
?例如,我只传递一个参数href。实际上,我有更多的参数,这些参数在结构化url中是不允许使用的字符。