通过PUT方法发送参数


Sending parametrs via PUT method

我使用php curl类

我有一个关于通过PUT方法发送参数的问题。

$array = array(
    'id' => $_REQUEST['id'],
    'name' => $_REQUEST['name'],
    'second_name' => $_REQUEST['second_name']
);
$curl = new Curl();
$curl->setHeader('Accept', 'text/json'); 
$curl->setBasicAuthentication('login', 'pass');
$curl->put('link');

我有一个数组,它正在获取GET/POST值。我需要用PUT方法发送它们。我该怎么做?

我可以为您提供一个示例,向您展示我是如何做到这一点的。

    $url = "http://domain.com";
    $this->curl = curl_init($url);
    curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($this->curl, CURLOPT_POSTFIELDS, $array);
    curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($this->curl, CURLOPT_HTTPPROXYTUNNEL, true);

我希望这能帮助你。。。