Pyramid Power
Pyramid Power

Reputation: 35

PHP Curl Force Content-Type

Even though I set the content type to text/plain, CURLOP_POSTFIELDS appears to be overwriting it to 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",

Upvotes: 1

Views: 2082

Answers (1)

user2557188
user2557188

Reputation: 150

You'll have to remove the colon after Content-Type. Otherwise, try this:

$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);

Upvotes: 2

Related Questions