Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.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 无法获取PUT参数Phalcon Oauth2服务器_Php_Api_Rest_Oauth_Phalcon - Fatal编程技术网

Php 无法获取PUT参数Phalcon Oauth2服务器

Php 无法获取PUT参数Phalcon Oauth2服务器,php,api,rest,oauth,phalcon,Php,Api,Rest,Oauth,Phalcon,我在获取PUT请求数据时遇到问题 我遵循这个框架项目: 当我发送PUT请求时, 结果总是空数组 我尝试更改了几个代码: micro.php 以前 之后 我在vendor/Oauth2/src/Oauth2/Server/Storage/Pdo/Mysql/request.php中添加了PUT请求的新方法 public function put($index = NULL) { // print_r($this->request->getPut()); // I can se

我在获取PUT请求数据时遇到问题

我遵循这个框架项目:

当我发送PUT请求时, 结果总是空数组

我尝试更改了几个代码:

micro.php 以前

之后

我在vendor/Oauth2/src/Oauth2/Server/Storage/Pdo/Mysql/request.php中添加了PUT请求的新方法

public function put($index = NULL)
{
    // print_r($this->request->getPut()); // I can see the PUT request data here
    return $this->request->getPut($index);
}
class Request implements RequestInterface
{
protected $get = array();
protected $post = array();
protected $cookies = array();
protected $files = array();
protected $server = array();
protected $headers = array();
protected $put = array(); // new property added

// new $put parameter added */
public function __construct(array $get = array(), array $post = array(), array $put = array(), array $cookies = array(), array $files = array(), array $server = array(), $headers = array())
{
    $this->get = $get;
    $this->post = $post;
    $this->put = $put;
    $this->cookies = $cookies;
    $this->files = $files;
    $this->server = $server;

    if (empty($headers)) {
        $this->headers = $this->readHeaders();
    } else {
        $this->headers = $this->normalizeHeaders($headers);
    }
}

/* new method added */
public function put($index = null, $default = null)
{
    return $this->getPropertyValue('put', $index, $default);
}

....
还加入了 vendor/league/oauth2 server/src/league/oauth2/server/Util/RequestInterface.php

 public function put($index = null);
然后修改了这个类 vendor/league/oauth2 server/src/league/oauth2/server/Util/Request.php

public function put($index = NULL)
{
    // print_r($this->request->getPut()); // I can see the PUT request data here
    return $this->request->getPut($index);
}
class Request implements RequestInterface
{
protected $get = array();
protected $post = array();
protected $cookies = array();
protected $files = array();
protected $server = array();
protected $headers = array();
protected $put = array(); // new property added

// new $put parameter added */
public function __construct(array $get = array(), array $post = array(), array $put = array(), array $cookies = array(), array $files = array(), array $server = array(), $headers = array())
{
    $this->get = $get;
    $this->post = $post;
    $this->put = $put;
    $this->cookies = $cookies;
    $this->files = $files;
    $this->server = $server;

    if (empty($headers)) {
        $this->headers = $this->readHeaders();
    } else {
        $this->headers = $this->normalizeHeaders($headers);
    }
}

/* new method added */
public function put($index = null, $default = null)
{
    return $this->getPropertyValue('put', $index, $default);
}

....
有人能告诉我密码有什么问题吗


干杯。

您能否更改PUT请求的内容类型


我在PUT参数方面遇到了类似的问题,通过使用内容类型application/x-www-form-urlencoded解决了这个问题。尝试将其添加到请求类的headers数组。

这是区分大小写的问题吗?@JamesFenwick我不这么认为,似乎oauth服务器的库替换了getPut函数的实际值。