Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
Photo
- - - - -

Automatic Login Using Curl


18 replies to this topic

#1 rw4dmin

rw4dmin

    Newbie

  • Kontributors
  • Pip
  • 1 posts

Posted 22 June 2006 - 08:06 AM

If you'are lazy people like me. This script may help u. This script is to automated our login to some site.
You must have cURL installed to use this script.
<?php
// INIT CURL
$ch = curl_init();

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Login.php');

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'fieldname1=fieldvalue1&fieldname2=fieldvalue2');

// 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); 

?>

  • 0

#2 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 12 December 2007 - 08:23 PM

Well done. I used this script to reverse engineer dynamic daily emails on my website in conjuction with jetable.Org to avoid getting spammed. Thanks! :D

-Cliff Bennett
  • 0

#3 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 05 October 2008 - 12:39 PM

Great Stuff
Automatic Login Using Curl

Wow, I've been through so many examples recently trying to login via curl and submit data to a database but could not get it to work due to cookies etc but this worked like a charm! I just wish I'd found your example 6-7 hours ago!! Thank you!

-reply by denise
  • 0

#4 harrison858

harrison858

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 315 posts
  • Gender:Male
  • myCENT:27.33

Posted 29 October 2008 - 06:36 PM

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

#5 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 31 October 2008 - 05:13 AM

How we set cookie?
Automatic Login Using Curl

Replying to harrison858

Still not login by using is script

-reply by Nasir Ali Shah
  • 0

#6 liod

liod

    Member [Level 1]

  • Kontributors
  • PipPipPipPip
  • 73 posts

Posted 31 October 2008 - 09:46 AM

Thank you brother.
It`s a small script, but it very help me.
  • 0

#7 shadowx

shadowx

    Live your life so that in death you may stand side by side with your gods. Not at their feet.

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1,674 posts
  • Gender:Male
  • Location:Essex, UK
  • Interests:Photography is a big interest, i have some photos up at my site, apex photographs (http://apex-photographs.com). Using my Lumix g1 to take the photos of course! <br /><br />Um computer games... photo editing and thats about it!
  • myCENT:68.57
  • Spam Patrol

Posted 01 November 2008 - 01:04 PM

AHA! youve answered a question i couldnt be bothered to ask!

I needed to login to a page with a GET var to the page i want, then be redirected to the page i want (now logged in) and decrypt some text and i was getting stuck at sending POST vars but now it may be solved!

Thanks!

Nice code too :lol: Good use of comments!
  • 0

#8 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 27 March 2009 - 12:45 PM

Username/PasswordAutomatic Login Using Curl

How do I designate a username and password to use in the Automatic Login Using cURL script?


  • 0

#9 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 19 April 2009 - 09:59 AM

Great Code - Thanks!Automatic Login Using Curl

Thanks for the great code it was exactly what I needed to automate the crediting on my site for those annoying affiliate networks that refuse to use postback URLs!  It couldn't have been more customized to fit my needs!

Regards,Tom Guilleaume


  • 0

#10 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 04 June 2009 - 01:33 PM

Clear Example Of Curl.Automatic Login Using Curl

This was my first time attempting Curl and with your concept it made it easy to understand. Thank you for your post with the code.

-feedback by Mark
  • 0

#11 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 19 September 2009 - 11:16 AM

hey,Thanks for script you wrote.It works for some system.For some system I receive message "Object moved to here.".Can you suggest me what could be the reason for this?-reply by vishal
  • 0

#12 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 14 November 2009 - 04:57 AM

didnAutomatic Login Using Curl

 hi, the CURL script didn't word on nginx http server, anyone know how to fix this ? the nginx return 404 response (not found)

Thanks  

-reply by sapta
  • 0

#13 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 28 December 2009 - 05:13 AM

Regarding automatic login using curlAutomatic Login Using Curl

Hi there,

whether cookie file path inclusion is compulsory or not..?

Thanks,

Ars


  • 0

#14 iGuest

iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 16 March 2010 - 05:07 AM

curl auto login with webdav serverAutomatic Login Using Curl

Hi, I would like to know the possibilities to use the above script for WEBDAV log in.

Webdav will ask for windows authentication. Can we override this using curl.

Thanks in advance!!

Vijay


  • 0

#15 jhbalaji

jhbalaji

    Newbie

  • Kontributors
  • Pip
  • 1 posts

Posted 18 May 2010 - 04:21 PM

Hey!
Where i need to insert the username and password :)
  • 0



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users