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 如何向phil sturgeon发送删除请求';s-codeigniter restserver_Php_Codeigniter_Rest - Fatal编程技术网

Php 如何向phil sturgeon发送删除请求';s-codeigniter restserver

Php 如何向phil sturgeon发送删除请求';s-codeigniter restserver,php,codeigniter,rest,Php,Codeigniter,Rest,正如标题所说,我将Codeigniter与phil sturgeon一起使用-Codeigniter restserver框架 我遵循了上的教程,除了发送删除请求外,其他一切都可以正常工作 代码: 根据HTTP规范删除无法发送参数。它可以在URL中包含内容,因此您可以将其更改为: public function user_delete($id) { $this->response(array( 'returned from delete:' => $id,

正如标题所说,我将Codeigniter与phil sturgeon一起使用-Codeigniter restserver框架

我遵循了上的教程,除了发送删除请求外,其他一切都可以正常工作

代码:


根据HTTP规范删除无法发送参数。它可以在URL中包含内容,因此您可以将其更改为:

public function user_delete($id)
{
    $this->response(array(
        'returned from delete:' => $id,
    ));
}

我在这项工作中遇到了同样的问题

1->在REST\u Controller.php中将默认的_parse\u delete()函数替换为:

protected function _parse_delete()
{
    $this->_delete_args = $_DELETE;
    $this->request->format and $this->request->body = file_get_contents('php://input');
    // Set up out DELETE variables (which shouldn't really exist, but sssh!)
    parse_str(file_get_contents('php://input'), $this->_delete_args);
}

就这些!“如何使用phil sturgeon发送删除请求”的标题不再需要“用户删除($id)”

+1“谢谢注意,我一定会编辑它:)看看这个要点:Gist.github.com/Ema4rl/aebb63db1c76786c9cba811d69339fd3Thanks Phil,顺便说一句,很棒的FW:)。因此,我想关于Nettuts的教程没有更新,因为代码就在那里。此外,url应该是:(删除/id/)只是一条评论,但你不应该使用类似
localhost/api/client/user/delete/1
之类的东西吗?ftom2:互联网是一个档案,不是每一篇文章都会被永久保存,如果我想的话,我不能这样做。迈克:你为什么要这样做?Twitter污染了人们对RESTAPI的认识。添加“delete”不仅过于冗长(一个名为“delete”的HTTP头已经这样做了),而且非常不安全。如果你使用任何“获取可用URL”进行破坏性操作,那么你将面临一系列荒谬的安全问题——以及内容的意外删除。谢谢@PhilSturgeon——你的库对我非常有用。我希望他们尽快更新tute,因为这可能会让很多人感到沮丧。请查看以下要点:Gist.github.com/Ema4rl/aebb63db1c76786c9cba811d69339fd3
protected function _parse_delete()
{
    $this->_delete_args = $_DELETE;
    $this->request->format and $this->request->body = file_get_contents('php://input');
    // Set up out DELETE variables (which shouldn't really exist, but sssh!)
    parse_str(file_get_contents('php://input'), $this->_delete_args);
}