Jump to content
xisto Community
Sign in to follow this  
rw4dmin

Automatic Login Using Curl

Recommended Posts

OMG! That was exactly what I was looking for, and it took me forever to find a script.Thanks, now I will use it :)



>> Pls show me where is my errors in this code :

<?php// INIT CURL$ch = curl_init();// SET URL FOR THE POST FORM LOGINcurl_setopt($ch, CURLOPT_URL, 'http://http://www.vn-zoom.com/index.php;);// ENABLE HTTP POSTcurl_setopt ($ch, CURLOPT_POST, 1);// SET POST PARAMETERS : FORM VALUES FOR EACH FIELDcurl_setopt ($ch, CURLOPT_POSTFIELDS, 'vb_login_username=meomunsocola&vb_login_password=t13h6x');// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIEScurl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL# not to print out the results of its query.# Instead, it will return the results as a string return value# from curl_exec() instead of the usual true/false.curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);// EXECUTE 1st REQUEST (FORM LOGIN)$store = curl_exec ($ch);// SET FILE TO DOWNLOADcurl_setopt($ch, CURLOPT_URL, 'http://forums.xisto.com/no_longer_exists/;);// EXECUTE 2nd REQUEST (FILE DOWNLOAD)$content = curl_exec ($ch);// CLOSE CURLcurl_close ($ch); ?>

Share this post


Link to post
Share on other sites

>> Pls show me where is my errors in this code :

<?php// INIT CURL$ch = curl_init();// SET URL FOR THE POST FORM LOGINcurl_setopt($ch, CURLOPT_URL, 'http://forums.xisto.com/no_longer_exists/;);// ENABLE HTTP POSTcurl_setopt ($ch, CURLOPT_POST, 1);// SET POST PARAMETERS : FORM VALUES FOR EACH FIELDcurl_setopt ($ch, CURLOPT_POSTFIELDS, 'vb_login_username=meomunsocola&vb_login_password=t13h6x');// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIEScurl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL# not to print out the results of its query.# Instead, it will return the results as a string return value# from curl_exec() instead of the usual true/false.curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);// EXECUTE 1st REQUEST (FORM LOGIN)$store = curl_exec ($ch);[b]// SET FILE TO DOWNLOADcurl_setopt($ch, CURLOPT_URL, 'http://http://ww1.external-site.com/rg-erdr.php?_rpo=t;);[/b]// EXECUTE 2nd REQUEST (FILE DOWNLOAD)$content = curl_exec ($ch);// CLOSE CURLcurl_close ($ch); ?>

Your error is in the download URL. Your trying to download a file from a page you haven't logged into ;)

Share this post


Link to post
Share on other sites

I am having getting the script to work, and I think it is due to my username. My username contains both the "@" and "." symbol.For the "@" I understand I can use %40, however what is the value I should use for "."the value i am trying to pass is email_name@domain.com

Share this post


Link to post
Share on other sites

Hello. I have tried for two days to get this working, but I can't quite do it. Please help.

You can log into the site I want to get info from by going to this URL:
website.ord

It then redirects you to the home page (https://www.website.com/)

This is the code I am using:

<?php// INIT CURL$ch = curl_init();// SET URL FOR THE POST FORM LOGINcurl_setopt($ch, CURLOPT_URL, 'https://http://forums.xisto.com/no_longer_exists/;);// ENABLE HTTP POSTcurl_setopt ($ch, CURLOPT_POST, 1);// SET POST PARAMETERS : FORM VALUES FOR EACH FIELDcurl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=admin@othersite.com&password=123password');// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIEScurl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL# not to print out the results of its query.# Instead, it will return the results as a string return value# from curl_exec() instead of the usual true/false.curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);// EXECUTE 1st REQUEST (FORM LOGIN)$store = curl_exec ($ch);echo "store: " . $store . "<br />";// SET FILE TO DOWNLOADcurl_setopt($ch, CURLOPT_URL, 'http://forums.xisto.com/no_longer_exists/;);// EXECUTE 2nd REQUEST (FILE DOWNLOAD)$content = curl_exec ($ch);echo "content: " . $content . "<br />";// CLOSE CURLcurl_close ($ch);?>

The result is just a blank page (or store: content: with my 'echo's in the code).

Any help appreciated! Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.