0

Content type always null when passing on production server

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://xxxxx/oauth2/token");
$params = http_build_query(array(
    'redirect_uri' => 'http://xxxx',
    'grant_type' => 'authorization_code',
    'code' => '3423424234'
));
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/x-www-form-urlencoded',$encodeID)); //setting custom header
curl_setopt($curl, CURLOPT_POST,1);
curl_setopt($curl, CURLOPT_POSTFIELDS,$params);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);

if(curl_exec($curl) === false)
{
    echo 'Curl error: ' . curl_error($curl);
}

curl_close($curl);

and this is my output from the following curl response

["url"]=> string(41) "https://xxxx/oauth2/token" ["content_type"]=> NULL ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(0) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0) ["namelookup_time"]=> float(0) ["connect_time"]=> float(0) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(0) "" ["certinfo"]=> array(0) { } ["primary_port"]=> int(0) ["local_ip"]=> string(0) "" ["local_port"]=> int(0)

Please help thanxs :-)

9
  • try rewriting the http header array as the answer in this post Commented Feb 26, 2016 at 12:18
  • Tried already but same result Commented Feb 26, 2016 at 12:32
  • What's in the $encodeID ? Commented Feb 26, 2016 at 12:43
  • Authorization: Basic base64encode(client_id:client_secret) Commented Feb 26, 2016 at 12:47
  • Any possibility to add the content-length to the headers and test it? because the links that I have visited have content-length accompanying the content-type. Commented Feb 26, 2016 at 12:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.