note 94405 added to function.curl-setopt

From: Date: Tue, 03 Nov 2009 07:01:00 +0000
Subject: note 94405 added to function.curl-setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-162351@lists.php.net to get a copy of this message
Following from the comment made by Stan van de Burgt, if you change the post array to a string, PHP creates the post data successfully. As a quick and dirty example of implementing this fix: <?php $ch = curl_init; $url = 'http://www.example.com'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); foreach ($postData as $var) if (strpos($var, '@') === 0) { $postAsString = true; } if ($postAsString === true) { $str = ''; foreach ($postData as $key => $val) { $str .= '&' . $key . '=' . $val; } $postData = substr_replace($str, '', 0, 1); } curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_exec($ch); ?> Hopefully this error gets fixed at a lower level in the PHP cURL library itself to stop the need for this ugly workaround. ---- Server IP: 117.55.229.1 Probable Submitter: 203.14.171.241 ---- Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php Edit -- https://master.php.net/note/edit/94405 Del: integrated -- https://master.php.net/note/delete/94405/integrated Del: useless -- https://master.php.net/note/delete/94405/useless Del: bad code -- https://master.php.net/note/delete/94405/bad+code Del: spam -- https://master.php.net/note/delete/94405/spam Del: non-english -- https://master.php.net/note/delete/94405/non-english Del: in docs -- https://master.php.net/note/delete/94405/in+docs Del: other reasons-- https://master.php.net/note/delete/94405 Reject -- https://master.php.net/note/reject/94405 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162351) next »