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

curl-and-php

Re: Posting with an automatic hidden post

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 4 Feb 2009 08:54:55 +0100 (CET)

On Tue, 3 Feb 2009, Andrey Kuznetsov wrote:

> I too wouldn't mind an answer for this.
> Daniel Stenberg I believe you didn't understand what he was trying to say.

I believe the contrary. You need to realize what HTTP is and how it works. You
_either_ do a GET or you do a POST. libcurl does one of these operations, it
does not magically do a GET when you issue a POST (with the exeception being
if you enable redirect-following as then libcurl can do a follow-up request
that can be different but then you asked for it).

> The situation is, every new page, there is a new key.

With every GET I would presume.

> The way to get that key, is to use curl to go to that url, execute the
> handle to get the output data, scrape the key, then here is the problem, how
> do you submit POST command using postfield( to submit the key+data) to that
> same url without executing a new handle because you already executed the
> last handle. Therefor in order to submit a post, the page has to be reloaded
> using a new\same handle, so the page will be refreshed.

Nope. You GET the page first and you extract all the info you need. Then you
POST the data back. The POST does not "reload" any page at all.

> I don't think curl can load the page, output it to a variable and then
> POST all using 1 execute command.

HTTP is stateless and thus it doesn't matter if you can do this in one go or
in two. The effect is exactly the same.

1. GET
2. extract data
3. POST
4. smile

-- 
  / daniel.haxx.se
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-02-04