cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to keep a cURL handle open, to post image verfication code

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 9 May 2007 12:18:49 -0700

On Wed, May 09, 2007 at 11:19:26AM -0700, Znigniew Widomski wrote:
> Hello I'm using the curl library in php. I'm trying to post to a form with POST

You might consider the PHP/CURL mailing list for such questions in the
future.

> but the form requires that a code be entered for image verification. So
> basically what I need to do is first is load the form and grab the contents
> from the form, and echo out the image for verification. Then I physically type
> the code into a custom form of my own, and press submit. Then curl will load
> the SAME surf session or form and submit to the form with the image
> verification code. The problem is normally when you make two curl_init it loads
> the page twice, if I load the form twice there will be a different image
> verfication code when I submit the code.

Is your custom form sending to the correct post URL, or are you attempting
to post to the HTML form page? You're probably missing some state information
to connect the image to your response.

> I need to somehow keep the "surf session" open or handle or something, so when
> I post to the form with the image verfication I read earlier, it will be the
> same image verification code that it requires.
>
> Can anyone tell how this can be done wiht curl??

libcurl does this by default on HTTP/1.1 servers. With the C binding, you
simply reuse the easy handle without cleaning it between transfers. But
that's not what you want here. HTTP is stateless (Microsoft bastardizations
thereof excepted). The state which is needed by the server to connect the
image it sent with your response is probably held in a hidden form or in a
cookie. Try enabling libcurl's cookie handling and look for hidden form
fields and try again.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-05-09