note 84916 added to function.curl-setopt
| From: | fred at themancan dot com | Date: | Tue, 05 Aug 2008 23:28:29 +0000 |
| Subject: | note 84916 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143189@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 208.69.120.35
Probable Submitter: 24.16.251.185
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/84916
Del: integrated -- https://master.php.net/note/delete/84916/integrated
Del: useless -- https://master.php.net/note/delete/84916/useless
Del: bad code -- https://master.php.net/note/delete/84916/bad+code
Del: spam -- https://master.php.net/note/delete/84916/spam
Del: non-english -- https://master.php.net/note/delete/84916/non-english
Del: in docs -- https://master.php.net/note/delete/84916/in+docs
Del: other reasons-- https://master.php.net/note/delete/84916
Reject -- https://master.php.net/note/reject/84916
Search -- https://master.php.net/manage/user-notes.php