curl-and-php
Navigating website with curl lib
Date: Sun, 1 Jul 2007 18:30:11 -0400
I am running this as a script from the command line on my FreeBSD system.
10.0.10.3 is the LAN ip address for this box and the Apache13 server is on
the same box.
The website can be reached from the public internet with
www.mls.a1poweruser.com
and curltest is the login id and password.
This is my development demo website so no problem playing with it.
The Captcha Security Code Random-Noisy-Images of the login
page has been deactivated for this testing.
I am trying to navigate down to the member_update page and make changes.
My understanding from reading the libcurl info is each page wanted must be
gotten with it's own curl_exec and any setopt's done in the first curl_exec
are in effect for all following curl_exec. Is this correct?
The CURLOPT_COOKIEJAR saves the cookies on the first curl_exec and
all following curl_exec use the CURLOPT_COOKIEFILE.
Is my understanding correct?
Where is the CURLOPT_COOKIEJAR, "-" statement really putting the cookies?
When I run this script I get the url1 page html code displayed along with
the verbose
stuff and it hangs keeping the virtual console open. I have to ctrl/c to
exit it.
What kind of debug code can I add to see what is really happening?
Is there some way to select the LINK on a retrieved page to follow?
Does libcurl work with framed pages?
#! /usr/local/bin/php
<?php
set_time_limit(3);
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
$ref = "http://www.test.curl.net";
$url1 = 'http://10.0.10.3/mls/mls_fsbo_logon.php';
$url2 = 'http://10.0.10.3/mls/mls_fsbo_menu.php';
$url3 = 'http://10.0.10.3/mls/mls_fsbo_member_update.php';
#$url = 'http://www.mls.a1poweruser.com/mls_fsbo_logon.php';
# Get login page, post id/pw and save session cookies to pass on
$ch = curl_init("");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, "-");
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL,$url1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"id=curltest&pw=curltest&action=submit");
$buffer = curl_exec ($ch);
# get members menu page
curl_setopt($ch, CURLOPT_COOKIEFILE, "-");
curl_setopt($ch, CURLOPT_URL,$url2);
$buffer = curl_exec ($ch);
# get update members data page
curl_setopt($ch, CURLOPT_URL,$url3);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"zip=44026&action=submit");
$buffer = curl_exec ($ch);
curl_close ($ch);
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-07-02