Page 1 of 2
cUrl
Posted: Thu Mar 29, 2007 9:32 pm
by ol4pr0
Hi,
I have the following question, have been busy googling and searching around but couldnt find what i need.
iniate cUrl
post fields and login -- works fine untill here.
-------- kinda confused on how to do the following.
Now the using same curl session to open another url inside the protected site.
and post other fields
logout .
Posted: Thu Mar 29, 2007 9:56 pm
by Christopher
I am not exactly clear what you are asking. You may need to pass headers or maintain a cookie during the cURL session. Look in the cURL docs about those things.
Posted: Thu Mar 29, 2007 10:51 pm
by ol4pr0
Ok let me see if i can explain better
first page, has user and password -- this is no problem i pass have the curl follow redirect
Now i am in the main page after i logged in.
Now how do switch location once being here ?
menu has - link 1 , link 2 , link 3
I want to go to link 2, and from here use curl again to submit some data and logout !
Posted: Thu Mar 29, 2007 11:51 pm
by feyd
Extract link 2 from the returned page data then request it via the same curl resource.
Posted: Fri Mar 30, 2007 3:37 pm
by ol4pr0
Let me see if i understand you correctly.
I know the link, ofcourse i could do a preg_match which is no problem at all.
So what are saying basicly.
curl_init(login page)
post fields
curl_init(second link)
post fields
I have tried something simular locally but, that didnt really work at all.
Posted: Fri Mar 30, 2007 4:21 pm
by feyd
Keep trying. You may need to tweak the settings you place with cURL.
Posted: Fri Mar 30, 2007 4:23 pm
by ol4pr0
jejeje,,
I will, now do i , or do i not close first curl session or do i just use the same curl sessoin with the new url ?
eg: $c = curl_init(firsturl)
$c = curl_init(secondurl)
Posted: Fri Mar 30, 2007 4:25 pm
by feyd
If memory serves, it doesn't really matter either way as long as you set it up the same if you close it.
Posted: Thu Apr 05, 2007 6:00 pm
by ol4pr0
Ok, tried several options and cant figure this one out.
Code: Select all
$url = "full_url_login.php";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user:pass");
$url = "url2_afterlogin.php";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
echo $result; // echos 1, i am not sure if i am in second url. with fopen(sometext.txt) the file turns up empty
Am i missing something ?
Posted: Thu Apr 05, 2007 6:07 pm
by feyd
You didn't set it up the same.
Posted: Thu Apr 05, 2007 6:08 pm
by ol4pr0
Excuse me, ?
ps: dont u ever sleep
Posted: Thu Apr 05, 2007 6:37 pm
by feyd
"user:pass" need to be passed for each request more than likely.
Posted: Thu Apr 05, 2007 6:44 pm
by ol4pr0
Done that, no luck.
I am not trying to create some lame hotmail grabber. Just trying to automate creating email aliases.
Posted: Thu Apr 05, 2007 8:10 pm
by John Cartwright
You only need 1 call to curl_init(). Right now, you are overwritting the previous curl session.
Posted: Fri Apr 06, 2007 8:45 pm
by ol4pr0
OK,
And how am i suppose to do that, changnig links using Curl.