cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Post Any Form / Unknown fields

From: William Crandell <william+curl_at_webwizardwill.com>
Date: Wed, 24 Feb 2010 19:14:04 -0500

I have been trying to figure out a way to post different forms. I
explicitly trust the remote server and want to be able to use cURL to
display the remote site to the client. I also want all the forms to work.
 Well some of the forms work while others don't.
The main feature I am trying to achieve is allowing the 3rd party server to
change their forms/fields without notice to me, while maintaining a working
cURL based web app.
The source line that I am currently using does not work 100%. At least it
eludes me as to why my current script works on some forms and not others.
 Anyhow on to the code:

################################
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $fileUrl );
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $Cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookie);
if (isset($_POST)) {
  foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
    }
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
}
$homepage = curl_exec ($ch) or die ("Couldn't connect to $fileUrl1.");
curl_close ($ch);
echo = $homepage;
################################

Any suggestions?

Of course I have a few other things happening before and after, though I am
sure the problem exists within the above code.
Thanks.

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2010-02-28