Page 1 of 1
CURL Login
Posted: Fri Mar 09, 2007 11:55 pm
by SidewinderX
Ive created a script to login to a site which works fine, but when I login, that site has an iframe I want to grab data from. The problem is the iframe displays a 404 error because the file it is looking for is account.php which is not on my server, but the server i am logging into.
Using my script, how can I get access to the file thats in the iframe?
Code: Select all
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/");
curl_setopt($ch, CURLOPT_COOKIEFILE, "C:/");
curl_setopt($ch, CURLOPT_URL, $host."/myaccount.php?");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "login_username=".$username."&login_password=".$password."");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_exec($ch);
curl_close ($ch);
?>
Posted: Fri Mar 09, 2007 11:57 pm
by feyd
Provide a full path to cURL.
Posted: Sat Mar 10, 2007 12:04 am
by SidewinderX
Well $host is the full name of the place I'm trying to login to, in essence
$host = "
http://www.extreme-hq.com/test";
Is that what you mean?
Posted: Sat Mar 10, 2007 1:09 am
by SidewinderX
Well I know the answer feyd posted above is the correct one (when is he ever wrong

) But as usual I have no idea what he means, usually I can figure it out by playing with it and googleing for a while but I'm stumped, can someone translate / elaborate on that for me?
Thanks
What is the URL that you are trying to CURL?
Posted: Sat Mar 10, 2007 2:03 am
by afbase
What is the URL that you are trying to CURL?
^^^^^I believe this is what feyd was asking^^^^^
I'm no expert but maybe you need to put a "?" at the end of your $host url
Posted: Sat Mar 10, 2007 7:03 am
by feyd
No, I'm not asking anything.
There are two URLs involved in this problem:
- the login
- the frame
You must supply a fully-qualified URL to cURL so it may load each.
The resulting page from calling the login URL should be analyzed by the script to verify a correct login. Only upon success should it continue to attempt to fetch the frame providing that server with the produced credentials in any cookies it may have set.
Posted: Sat Mar 10, 2007 12:46 pm
by SidewinderX
Where / How do you supply a fully-qualified URL to cURL so it can load each?
Posted: Sat Mar 10, 2007 12:51 pm
by feyd
Note the CURLOPT_URL in the code you've posted in this thread already.
Posted: Sat Mar 10, 2007 6:12 pm
by afbase
why not set the host as follows?
Code: Select all
$host = "http://www.extreme-hq.com/test/myaccount.php?";
Posted: Sat Mar 10, 2007 6:45 pm
by AKA Panama Jack
And why are you tacking on a ? to the url when you are posting the variables?
Posted: Sat Mar 10, 2007 7:48 pm
by SidewinderX
afbase wrote:why not set the host as follows?
Code: Select all
$host = "http://www.extreme-hq.com/test/myaccount.php?";
I suppose I could, but that dosnt change much, just makes it better looking afaik
AKA Panama Jack wrote:And why are you tacking on a ? to the url when you are posting the variables?
I have no idea, I suppose it is redundant but the login part works, does that effect the iframe?