| |
|
Welcome to KnowledgeSutra - Dear Guest | |
Automatic Login Using Curl
Started by rw4dmin, Jun 22 2006 08:06 AM
18 replies to this topic
#16 Guest_Mr IvIeoh_*
Posted 07 April 2011 - 10:15 AM
harrison858, on 29 October 2008 - 06:36 PM, said:
OMG! That was exactly what I was looking for, and it took me forever to find a script.
Thanks, now I will use it
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 LOGIN curl_setopt($ch, CURLOPT_URL, 'http://www.vn-zoom.com/login.php?do=login'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'vb_login_username=meomunsocola&vb_login_password=t13h6x'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_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 DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Downloads/AnnualReport.pdf'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); ?>
#17 Guest_Gizmo_*
Posted 11 June 2011 - 12:10 PM
Mr IvIeoh, on 07 April 2011 - 10:15 AM, said:
>> Pls show me where is my errors in this code :
<?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://www.vn-zoom.com/login.php?do=login'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'vb_login_username=meomunsocola&vb_login_password=t13h6x'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_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 DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Downloads/AnnualReport.pdf');[/b] // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); ?>
Your error is in the download URL. Your trying to download a file from a page you haven't logged into
#18 Guest_Mike_*
Posted 27 November 2011 - 09:34 AM
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
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
#19 Guest_kleinbaas_*
Posted 12 February 2012 - 07:56 PM
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:
https://www.website....ord=123password
It then redirects you to the home page (https://www.website.com/)
This is the code I am using:
The result is just a blank page (or store: content: with my 'echo's in the code).
Any help appreciated! Thanks
You can log into the site I want to get info from by going to this URL:
https://www.website....ord=123password
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 LOGIN curl_setopt($ch, CURLOPT_URL, 'https://www.website.com/website_update.php?task=login&'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=admin@othersite.com&password=123password'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_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 DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://www.website.com/stuff/morestuff/'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); echo "content: " . $content . "<br />"; // CLOSE CURL curl_close ($ch); ?>
The result is just a blank page (or store: content: with my 'echo's in the code).
Any help appreciated! Thanks
Reply to this topic

1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users














