如何使用curl和Authorization执行PUT请求?

时间:2017-06-13 07:18:59

标签: php curl

这就是我正在尝试的

$url = "https://aon-test.yui.com/api/".$this->_token."/".$action; 
        $headers = array(
            'Content-Type:application/xml' ,
            'Authorization: Basic '. base64_encode("s!YIYIYIYIUYIY:X")
        );
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_setopt($ch, CURLOPT_HEADER, false);    
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30000);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($xml));
        $content = curl_exec($ch);
        curl_close($ch);

我收到500 - 内部服务器错误。 我在这做什么错?

0 个答案:

没有答案