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

curl-and-php

Re: Posting with an automatic hidden post

From: Andrey Kuznetsov <kandrey89_at_gmail.com>
Date: Wed, 4 Feb 2009 00:11:00 -0800

Explain this:

curl_init
URL
CURLOPT_RETURNTRANSFER
CURLOPT_FOLLOWLOCATION
curl_exec
extract key
URL
CURLOPT_POSTFIELDS
curl_exec
curl_close

upon the 2nd url\curl_exec the page is reloaded, OR does curl-php work
such that every line is executed as it is written, and does not buffer
url, return transfer, post-true, etc... until curl_exec is issued?

On Tue, Feb 3, 2009 at 11:54 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> 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
>

-- 
Remember The Past, Live The Present, Change The Future
Those who look only to the past or the present are certain to miss the
future [JFK]
kandrey89@gmail.com - http://discovery-scitech.blogspot.com -
http://kandrey89.dyndns.dk
Live Long and Prosper,
Andrey
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-02-04