johnpresta Posted April 28, 2011 Share Posted April 28, 2011 Hi Has anyone successfully managed to log into PS using CURL (front end login as a customer). Ive been working with the following code but just dont seem to be getting anywhere.$url = 'xxxxx';$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url );curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE );curl_setopt($ch, CURLOPT_COOKIEJAR, realpath('cookie.txt'));curl_setopt($ch, CURLOPT_COOKIEFILE, realpath('cookie.txt'));curl_setopt($ch, CURLOPT_HEADER, TRUE );$ret = curl_exec($ch);if (!preg_match('/name="([a-zA-z0-9]{32})"/', $ret, $spoof)) { preg_match("/name='([a-zA-z0-9]{32})'/", $ret, $spoof);}// POST fields$postfields = array();$postfields['email'] = $uname;$postfields['passwd'] = $upswd;$postfields[$spoof[1]] = '1';curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);$ret = curl_exec($ch);// Get logged in cookie and pass it to the browserpreg_match('/^Set-Cookie: (.*?);/m', $ret, $m);$cookie=explode('=',$m[1]);setcookie($cookie[0], $cookie[1]); Link to comment Share on other sites More sharing options...
Jovicyr Posted June 8, 2011 Share Posted June 8, 2011 Hello, I'm also interested by the answer.How did you manage it ?Thanks Link to comment Share on other sites More sharing options...
hornetbzz Posted June 8, 2011 Share Posted June 8, 2011 +1, trying the same but not successful yet.I guess a more simple solution shall exist, like So it looks like you have first to login in order to get the token and then log with the right form data AND the token. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now