note 84916 modified in function.curl-setopt by danbrown

From: Date: Sun, 17 May 2009 17:19:38 +0000
Subject: note 84916 modified in function.curl-setopt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154967@lists.php.net to get a copy of this message
To find what encoding a given HTTP POST request uses is easy -- passing an array to CURLOPT_POSTFIELDS results in multipart/form-data: <?php curl_setopt(CURLOPT_POSTFIELDS, array('field1' => 'value')); ?> Passing a URL-encoded string will result in application/x-www-form-urlencoded: <?php curl_setopt(CURLOPT_POSTFIELDS, array('field1=value&field2=value2')); ?> I ran across this when integrating with both a warehouse system and an email system; neither would accept multipart/form-data, but both happily accepted application/x-www-form-urlencoded. --was-- What encoding will a given HTTP POST request use? The answer is easy -- passing an array to CURLOPT_POSTFIELDS results in multipart/form-data: <?php curl_setopt(CURLOPT_POSTFIELDS, array('field1' => 'value')); ?> Passing a URL-encoded string will result in application/x-www-form-urlencoded: <?php curl_setopt(CURLOPT_POSTFIELDS, array('field1=value&field2=value2')); ?> I ran across this when integrating with both a warehouse system and an email system; neither would accept multipart/form-data, but both happily accepted application/x-www-form-urlencoded. http://php.net/manual/en/function.curl-setopt.php

« previous php.notes (#154967) next »