curl 7.10.6 (i386-redhat-linux-gnu) libcurl/7.10.6 OpenSSL/0.9.7a ipv6
zlib/1.1.4
Protocols: ftp gopher telnet dict ldap http file https ftps
Features: IPv6 SSL libz NTLM
==
PHP 5.0.2 (cgi) (built: Jul 10 2005 15:41:02)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.2, Copyright (c) 1998-2004 Zend Technologies
==
I can use CURL to retrieve a web-page but when I try to use POST, it
doesn't seem to actually post anything. The code is:
++++++++++++++++++++++++++++++++++++++++++++
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, True);
curl_setopt ($ch, CURLOPT_USERAGENT, $config['user_agent']);
curl_setopt ($ch, CURLOPT_HEADER, True);
curl_setopt ($ch, CURLOPT_VERBOSE, True);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, True);
global $errfile;
curl_setopt ($ch, CURLOPT_STDERR, $errfile);
curl_setopt ($ch, CURLOPT_FAILONERROR, True);
// If we have any cookies, send them with each request.
if (retrieve_cookies($cook))
curl_setopt($ch, CURLOPT_COOKIE, $cook);
// If the caller provided any POST variables, send them... properly
formatted.
if (!empty($postvars)) {
if (is_array($postvars)) {
$post = '';
$amper = '';
foreach ($postvars as $p=>$v) {
$post .= $amper . urlencode($p) . '=' . urlencode($v);
$amper = '&';
}
} else $post = $postvars;
echo ">>Sending POST vars: '$post'\n";
// e.g. "username=goofus&password=gallant"
curl_setopt ($ch, CURL_POST, True);
curl_setopt ($ch, CURL_POSTFIELDS, $post);
}
$data = curl_exec($ch);
Script debugging output confirms that "$post" does have a
properly-formatted string in it, e.g.
"username=goofus&password=gallant" And that CURL_POSTFIELDS is indeed
being called. But I see no indication that this data is making it to
the server.
The (sanitized...) VERBOSE logfile is:
=================================
* About to connect() to xxx.yyy.com:80
* Connected to aaa.bbb.net (11.22.33.44) port 80
GET /index.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Host: xxx.yyy.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
< HTTP/1.1 200 OK
< Date: ...
< Server: Apache ...
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/html
* Closing connection #0
==================================