Mailing Lists
| |
|
|
|
cURL Mailing List Monthly Index Single Mail
curl-and-php mailing list Archives
Re: POST problem
From: Alan Storm <gliff_at_rochester.rr.com>
Date: Sun, 30 May 2004 23:32:25 -0400
On 5/30/04, Stijn De Maesschalck typed
>If you want, you can take a look on
Your POST data isn't being sent.
CURLOPT_POSTFIELDS expects a URL encoded query string, not an
If your webmail app. requires cookies, you're going to need to muck
-- Alan Storm http://www.gliff.org +------------------------------------------------------------+ <?php //this function is passed an array, and returns a //url encoded query string. function encodeQueryString($array){ if(!is_array($array)){ die("Encode Post Array expects an array"); } $retValue = ''; for(reset($array);$key=key($array);next($array)){ $retValue .= $key."=".urlencode($array[$key])."&"; } //zap last & $retValue = substr($retValue, 0, -1); return $retValue; } ?> <?php $postdata['imapuser']="test"; $postdata['pass']="12345"; $postdata['actionid']="105"; $postdata['url']="http://webmail.info.czar.be/horde/login.php"; $postdata['mailbox']="INBOX"; $postdata['port']="143"; $postdata['server']="localhost"; $postdata['namespace']=""; $postdata['maildomain']="info.czar.be"; $postdata['protocol']="imap/notls"; $postdata['realm']="info.czar.be"; $postdata['folders']="INBOX."; $postdata['submit']="open+webmail"; //pass associative array to function that will //create an encoded query string $postdata = encodeQueryString($postdata); $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE,1); curl_setopt($ch, CURLOPT_URL, "http://webmail.info.czar.be/horde/login.php"); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // execute a POST request $result = curl_exec ($ch); curl_close($ch); print($result); ?> +------------------------------------------------------------+Received on 2004-05-31 These mail archives are generated by hypermail. |
Page updated November 12, 2010.
web site info