curl-and-php
How to POST a big amount of data?
Date: Mon, 18 Nov 2002 17:47:58 +0100
Hi all,
I work with Apache 2, PHP/4.3.0-pre2, OpenSSL/0.9.6g and libcurl 7.9.8 under
Windows NT.
I succedeed in posting data with the method GET with the following code:
/***I get access***/
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,
"https://my.server.com/servlet?login=mike&pass=foo");
curl_setopt($ch, CURLOPT_COOKIEJAR, "C:\Program Files\Apache
Group\Apache\htdocs\cookie.txt");
ob_start(); // prevent any output
curl_exec ($ch);
ob_end_clean();
/***I post my data***/
curl_setopt ($ch, CURLOPT_URL,
"https://my.server.com/servlet?var1=380&var2=yes...");
curl_exec ($ch); // execute the curl command
curl_close($ch);
But for another formular, I would need to post a lot of data and it was not
possible with this method
(I get an error telling me that the url that I send is too big...)
So CURLOPT_POST seemed to be a good way to do this job properly. So I made a
test on the previous form
with the following code:
$ch = curl_init();
$post = "login=mike&pass=foo...";
curl_setopt ($ch, CURLOPT_URL, "https://my.server.com/servlet");
curl_setopt($ch, CURLOPT_COOKIEJAR, "C:\cookie.txt");
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
ob_start(); // prevent any output
curl_exec ($ch);
ob_end_clean();
$post = "var1=380&var2=yes...";
curl_setopt ($ch, CURLOPT_URL, "https://my.server.com/servlet");
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_exec($ch);
As you saw I need to make several request to reach the final form where I
have to post my data.
The problem is that when I use CURLOPT_POSTFIELDS, it seems that all my
request have
to use the POST method, and some of my pages don't like it: "HTTP method
POST is not supported by this URL"
So I have to mix the two methods but I don't know if Curl allows that???
So my questions are:
- Is it possible to send a big amount of data with the GET method (it would
be great because it already works
for few data)!!!
- If not is it possible to mix POST and GET method?
Thanks a lot.
Regards.
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
Received on 2002-11-18