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 01:24:26 -0800

Got examples?? of 2. GET and 5. POST because i don't understand how
you are running the script without curl_exec.

Here is what my reference is to:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,
"http://127.0.0.1/posting.php?mode=newtopic&f=1");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$x = curl_exec($curl);
preg_match("#name=\"sid\" value=\"(.+?)\"#i", $x, $sid);
$sid = $sid[1];
$postdata = "text...whatever...$sid";
curl_setopt($curl, CURLOPT_URL,
"http://127.0.0.1/posting.php?mode=newtopic&f=1");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$x = curl_exec($curl);
curl_close($curl);

If I wanted to do all of this in 1 curl_exec step, how would I do it?
->since curl_exec reloads the page, or am I confusing something?

On Wed, Feb 4, 2009 at 12:59 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Wed, 4 Feb 2009, Andrey Kuznetsov wrote:
>
> (Your top-posting makes this thread very awkward to read and follow)
>
>> curl_exec=page refresh assuming it's the same url
>
> Yes, if you still does GET to that same URL. Which we've repeatedly said you
> don't.
>
>> Before you can extract data, you need to tell where you extract it from,
>> which is the variable that you set 1st curl_exec to. You extract the key,
>> then you select the same url, post command, and curl_exec the POST command.
>> Doesn't the 2nd curl_exec reload the page in order to know where to POST
>> command when it goes to the url thereby refreshing and changing the key?
>
> Nope.
>
> You (the app) tells where to send the POST, there's no magic involved from
> (lib)curl's end that figures out where to send that request.
>
> 1. Set URL1
> 2. GET 3. extract data
> 4. Set URL2 (or leave it the same as before)
> 5. POST
> 6. smile
>
> No "reload" nor "refresh".
>
> --
>
> / 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