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

curl-and-php

Re: Post Any Form / Unknown fields

From: Deepesh Malviya <deep0mal_at_gmail.com>
Date: Mon, 1 Mar 2010 13:08:03 +0530

Hi,

Some things which I can figure out from your code:

1. You are urlencoding and stripslashing the POST content, which might not
be a required as POST data goes in the body. I hope you are reversing these
items or the remote site during processing the form.
2. Your script only support single key value pair, not single key multiple
values.
3. Figuring out which form does not work exactly can help you in better way.

Hope this helps you.
Thanks
Deepesh

On Thu, Feb 25, 2010 at 5:44 AM, William Crandell <
william+curl_at_webwizardwill.com <william%2Bcurl_at_webwizardwill.com>> wrote:

> 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
>
>

-- 
_Deepesh

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