PHP卷曲力内容类型

时间:2013-07-08 07:43:18

标签: php ajax curl http-headers content-type

即使我将内容类型设置为text / plain,CURLOP_POSTFIELDS似乎也会将其覆盖为x-www-form-urlencoded

curl_setopt($ch, CURLOPT_POSTFIELDS, 'username etc..');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "type" => "POST",
    "Accept" => "*/*",
    "Content-Type:" => "text/plain; charset=utf-8",
    "X-AjaxPro-Method" => "Authenticate2",
    "Accept-Language" => "en-us,en;q=0.5",
    "Accept-Encoding" => "gzip, deflate",
    "Connection" => "keep-alive",

1 个答案:

答案 0 :(得分:2)

您必须在Content-Type后删除冒号。否则,试试这个:

$headers = array(
    'type: POST',
    'Accept: */*',
    'Content-type: text/plain; charset=utf-8',
    'X-AjaxPro-Method: Authenticate2',
    'Accept-Language: en-us,en;q=0.5',
    'Accept-Encoding: gzip, deflate',
    'Connection: keep-alive'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);