how to remote login with php curl ?

Discussion in 'PHP' started by l7azat88, May 11, 2011.

  1. #1
    i tired to know how to do that

    i wanna to know how to connect and login to another site with php .. ?
     
    l7azat88, May 11, 2011 IP
  2. Mak3MyDay

    Mak3MyDay Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Mak3MyDay, May 12, 2011 IP
  3. mofta7y

    mofta7y Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #3
    usually you have to do post request to the url of the login page

    a practical approch is

    1- open the html page that you want to mimic and search for the login form
    2- write down the form action url
    3- note down the form fields and their names

    then do the following request in curl (this is command line version you have to translate it to php)
    curl -X POST -d "username=value1&password=value2" FORMACTIONURL
     
    mofta7y, May 15, 2011 IP
  4. fabriciogr

    fabriciogr Active Member

    Messages:
    958
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    73
    #4
    like everyone has said you need to know a bit of cURL to get it to work. one thing missing in previous replies is that you need to keep the cookies. as i'm guessing you want to loing in remotely in order to do things as a logged in user.

    it's not complicated, you just need to read the cookies that were created when logged in and keep them.
     
    fabriciogr, May 15, 2011 IP
  5. x319

    x319 Well-Known Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    103
    #5
    You'll need to use cURL, find the field names that are posted in order to login to the site, and write a cURL script which will post to the site with the field names along with saving the session cookies.

    Refer to: http://curl.haxx.se/mail/archive-2003-05/0038.html
     
    x319, May 15, 2011 IP
  6. deviataz

    deviataz Active Member

    Messages:
    179
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    75
    #6
    Log on to the website you want to cURL using your own browser, export the cookies files and then load the cookies file with cURL like this: curl --cookie cookies.txt http://forums.digitalpoint.com
     
    deviataz, May 15, 2011 IP