#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    CURL and POST data for website okcupid.com


    hi,

    I'm trying to login with cURL, here's my code, but for some reason I always get a "guest" cookie.

    PHP Code:
    $username="xxx"
    $password="xxx"
    $url="(can't post links)://okcupid.com/login"
    $cookie="cookie.txt"

    $postdata "username=".$username."&password=".$password

    $ch curl_init();
    curl_setopt ($chCURLOPT_URL$url); 
    curl_setopt ($chCURLOPT_SSL_VERIFYPEERFALSE); 
    curl_setopt ($chCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
    curl_setopt ($chCURLOPT_TIMEOUT60); 
    curl_setopt ($chCURLOPT_FOLLOWLOCATION0); 
    curl_setopt ($chCURLOPT_RETURNTRANSFER1); 
    curl_setopt ($chCURLOPT_COOKIEJAR$cookie); 
    curl_setopt ($chCURLOPT_REFERER$url); 

    curl_setopt ($chCURLOPT_POSTFIELDS$postdata); 
    curl_setopt ($chCURLOPT_POST1); 
    $result curl_exec ($ch); 

    echo 
    $result;  
    curl_close($ch); 
    the cookie i get is
    Code:
    .okcupid.com	TRUE	/	FALSE	1383621437	guest	15740951221743387132
    and this is okcupids header sent when i login in chrome

    PHP Code:
    Request URL:xxxxs://www.okcupid.com/login
    Request Method:POST
    Status Code
    :302 OK
    Request Headersview source
    Accept
    :text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-US,en;q=0.8
    Cache-Control:max-age=0
    Connection:keep-alive
    Content-Length:57
    Content-Type:application/x-www-form-urlencoded
    Cookie:authlink=f870d65d; core=0dc1dc60_0.1.3.4.5.6.7.9.22.23.27.33.40.41.43.45.49.50.53.54.108_2.8.10.12.21.30.31.42.47.51.57.84_11.14.15.25.56.65.69.94_87; __qca=P0-436985492-1352084073180; nano=k%3Diframe_prefix_lock_-1%2Ce%3D1352091630912%2Cv%3D1; guest=10124066950966971211; __utma=190145652.1544842371.1352082754.1352082754.1352091631.2; __utmb=190145652.1.10.1352091631; __utmc=190145652; __utmz=190145652.1352082754.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
    Host:www.okcupid.com
    Origin:xxxx://www.okcupid.com
    Referer:xxxx://www.okcupid.com/logout
    User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
    Form Dataview URL encoded
    username:xxx
    password:xxx
    dest:/home
    Response Headersview source
    Connection:close
    Date:Mon, 05 Nov 2012 05:00:46 GMT
    Location:http://www.okcupid.com/home
    P3P:CP="NOI CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT", policyref="http://www.okcupid.com/w3c/p3p.xml"
    Server:OKWS/3.1.15.9
    Set-Cookie:session=13615928895210954110%3a6209522096584548404; expires=Tue, 05 Nov 2013 05:00:46 GMT; path=/; domain=okcupid.com
    Set-Cookie:guest=; expires=Sun, 04 Nov 2012 05:00:46 GMT; path=/; domain=okcupid.com 
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0

    Smile Any Luck Logging in to OKCwith CURL?


    Hi I'm trying to do the same thing. Have you had any luck getting this to work?

    Would you be willing to share any code updates so I can get mine working?

    If you didn't get it working, I can provide you a link to a project I found logging in with python.




    Originally Posted by durrrrr
    hi,

    I'm trying to login with cURL, here's my code, but for some reason I always get a "guest" cookie.

    PHP Code:
    $username="xxx"
    $password="xxx"
    $url="(can't post links)://okcupid.com/login"
    $cookie="cookie.txt"

    $postdata "username=".$username."&password=".$password

    $ch curl_init();
    curl_setopt ($chCURLOPT_URL$url); 
    curl_setopt ($chCURLOPT_SSL_VERIFYPEERFALSE); 
    curl_setopt ($chCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
    curl_setopt ($chCURLOPT_TIMEOUT60); 
    curl_setopt ($chCURLOPT_FOLLOWLOCATION0); 
    curl_setopt ($chCURLOPT_RETURNTRANSFER1); 
    curl_setopt ($chCURLOPT_COOKIEJAR$cookie); 
    curl_setopt ($chCURLOPT_REFERER$url); 

    curl_setopt ($chCURLOPT_POSTFIELDS$postdata); 
    curl_setopt ($chCURLOPT_POST1); 
    $result curl_exec ($ch); 

    echo 
    $result;  
    curl_close($ch); 
    the cookie i get is
    Code:
    .okcupid.com	TRUE	/	FALSE	1383621437	guest	15740951221743387132
    and this is okcupids header sent when i login in chrome

    PHP Code:
    Request URL:xxxxs://www.okcupid.com/login
    Request Method:POST
    Status Code
    :302 OK
    Request Headersview source
    Accept
    :text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-US,en;q=0.8
    Cache-Control:max-age=0
    Connection:keep-alive
    Content-Length:57
    Content-Type:application/x-www-form-urlencoded
    Cookie:authlink=f870d65d; core=0dc1dc60_0.1.3.4.5.6.7.9.22.23.27.33.40.41.43.45.49.50.53.54.108_2.8.10.12.21.30.31.42.47.51.57.84_11.14.15.25.56.65.69.94_87; __qca=P0-436985492-1352084073180; nano=k%3Diframe_prefix_lock_-1%2Ce%3D1352091630912%2Cv%3D1; guest=10124066950966971211; __utma=190145652.1544842371.1352082754.1352082754.1352091631.2; __utmb=190145652.1.10.1352091631; __utmc=190145652; __utmz=190145652.1352082754.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
    Host:www.okcupid.com
    Origin:xxxx://www.okcupid.com
    Referer:xxxx://www.okcupid.com/logout
    User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
    Form Dataview URL encoded
    username:xxx
    password:xxx
    dest:/home
    Response Headersview source
    Connection:close
    Date:Mon, 05 Nov 2012 05:00:46 GMT
    Location:http://www.okcupid.com/home
    P3P:CP="NOI CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT", policyref="http://www.okcupid.com/w3c/p3p.xml"
    Server:OKWS/3.1.15.9
    Set-Cookie:session=13615928895210954110%3a6209522096584548404; expires=Tue, 05 Nov 2013 05:00:46 GMT; path=/; domain=okcupid.com
    Set-Cookie:guest=; expires=Sun, 04 Nov 2012 05:00:46 GMT; path=/; domain=okcupid.com 
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Durrrrr never came back to the forum after posting his initial question. I doubt you'll get any response here.

    Why are you trying to write an automated script to log into OKC? Are you sure it's not against their terms of service to do so? Most of these bots are used to generate cyberbully websites so they don't get much community support.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by ManiacDan
    Durrrrr never came back to the forum after posting his initial question. I doubt you'll get any response here.

    Why are you trying to write an automated script to log into OKC? Are you sure it's not against their terms of service to do so? Most of these bots are used to generate cyberbully websites so they don't get much community support.
    Thanks for posting ManiacDan!

    I ended up getting curl working and my awesome site is up and runnig.

    I'm not sure its not against their policy, but at the moment I have my crawl rates set pretty low so I don't think i'm abusing it. maybe I'll get around to reading their terms and policy...

    Anyway thanks for posting!
    Last edited by ManiacDan; December 17th, 2013 at 08:08 AM.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    1
    Rep Power
    0
    Originally Posted by webalchemist
    Thanks for posting ManiacDan!

    I ended up getting curl working and my awesome site is up and runnig.

    I'm not sure its not against their policy, but at the moment I have my crawl rates set pretty low so I don't think i'm abusing it. maybe I'll get around to reading their terms and policy...

    Anyway thanks for posting!
    would you be willing to share your code? I'm attempting to do something sort of similar with curl and running into problems. Thanks!

IMN logo majestic logo threadwatch logo seochat tools logo