angelleye Posted April 9, 2008 Share Posted April 9, 2008 I work a lot with PayPal Web Services. When you test applications using PayPal's test servers you must first log into your account at http://developer.paypal.com. Only then will their test accounts work for you. This can be a real pain when trying to have clients test solutions you've developed for them, or even just the fact that you have to do that everytime. Kind of annoying. Is there any way I could login to the site as a first step in my test pages so I didn't actually have to manually do it? Any information on this would be greatly appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/ Share on other sites More sharing options...
ohdang888 Posted April 9, 2008 Share Posted April 9, 2008 why don't you just test it for them. Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512529 Share on other sites More sharing options...
angelleye Posted April 9, 2008 Author Share Posted April 9, 2008 I shouldn't have said test, I should have said demo. Of course I test it for them, and it's not a big problem for me. I can't allow them to demo it themselves, though. Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512550 Share on other sites More sharing options...
ohdang888 Posted April 9, 2008 Share Posted April 9, 2008 oh... well don't know enough javascript and php to do that.... but on the old projectplaylist.com site, you could put in your myspace password and it automatically signed you in and added the code to yout profile... so it can be done. Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512569 Share on other sites More sharing options...
discomatt Posted April 9, 2008 Share Posted April 9, 2008 Using cURL requests. This gets into some more advanced programming, as it requires sending proper headers.. and a little understanding of the HTTP protocol. If you'd like to learn though, the information is out there. Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512572 Share on other sites More sharing options...
angelleye Posted April 9, 2008 Author Share Posted April 9, 2008 Well, actually, I use curl in my current scripts to make XML/SOAP calls to the PayPal Web Services. I just include credentials in the SOAP requests, though, so I haven't had to dig too deep into actual curl headers. Can you possibly refer me to a good example of this being done? I'm having some trouble finding anything for some reason. Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512594 Share on other sites More sharing options...
discomatt Posted April 9, 2008 Share Posted April 9, 2008 http://www.wagerank.com/2007/how-to-submit-forms-with-php/ Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512616 Share on other sites More sharing options...
angelleye Posted April 9, 2008 Author Share Posted April 9, 2008 Hmmm...looks like a great source but I'm not having any luck. Following the instructions and using that FireFox tool I see that when I login it actually seems to go through a few pages. Here's what it gave me.. https://developer.paypal.com/cgi-bin/devscr?__track=_logout:login/main:_login-submit POST /cgi-bin/devscr?__track=_logout:login/main:_login-submit HTTP/1.1 Host: developer.paypal.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: https://developer.paypal.com/cgi-bin/devscr?cmd=_logout Cookie: homepage=3; upct=24; KHcl0EuY7AKSMgfvHl7J5E7hPtK=bFrgcM30Gb-2b3E85K4SiHyEzsMZeRVIqxjlur44o74QGXZnvTnHGme_QggT-eQFT34cVqPLl1OhGdE_; cookie_srd_optin=true; s_pers=%20s_favsn_paypalglobal_1%3D9856380030122%7C1505841661312%3B; cookie_check=yes; login_email=andrew%40angelleye.com; INSIDE_SEARCH_PARAMS=2%3bUS%3ben_US%3bAmerica%2fLos_Angeles; navlns=0; LANG=en_US%3bUS; nMjq0zk0-yCYE_iBONIGREETTNW=; dev_login_email=andrew%40angelleye.com; wwp_ClJZM3hWN6BNtpFD0LimhmC=; __login_track=SJZDNH8fctvqVf3Kf226tZyuuqtefbzza2dCsGL5wgEnnp25shrKG7LFry0 Content-Type: application/x-www-form-urlencoded Content-Length: 116 cmd=_login-submit&login_cmd=&login_params=&login_email=LOGIN_EMAIL&login_password=LOGIN_PW&submit=Log+In HTTP/1.x 302 Found Date: Wed, 09 Apr 2008 05:21:28 GMT Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a mod_fastcgi/2.4.2 PHP/4.3.2 Cache-Control: private Expires: Thu, 05 Jan 1995 22:00:00 GMT Pragma: no-cache Set-Cookie: nMjq0zk0-yCYE_iBONIGREETTNW=Jpm8RBa7sT64hIbo8v2itdfrzX6QWIO7bstdDvYj-dzgOOwis787txlMhLTiBzIPKo7tuLE2flqqRVTd3ISWJF63NnC; expires=Sat, 06-Sep-2008 05:21:31 GMT; path=/; domain=.paypal.com Set-Cookie: dev_login_email=andrew%40angelleye.com; expires=Mon, 06-Oct-2008 05:21:31 GMT; path=/; domain=.paypal.com Set-Cookie: wwp_ClJZM3hWN6BNtpFD0LimhmC=; path=/; domain=.paypal.com Set-Cookie: __login_track=SJZDNH8fctvqVf3Kf226tZyuuqtefbzza2dCsGL5wgEnnp25shrKG7LFry0; path=/; domain=.paypal.com Location: https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 ---------------------------------------------------------- https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0 GET /cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0 HTTP/1.1 Host: developer.paypal.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: https://developer.paypal.com/cgi-bin/devscr?cmd=_logout Cookie: homepage=3; upct=24; KHcl0EuY7AKSMgfvHl7J5E7hPtK=bFrgcM30Gb-2b3E85K4SiHyEzsMZeRVIqxjlur44o74QGXZnvTnHGme_QggT-eQFT34cVqPLl1OhGdE_; cookie_srd_optin=true; s_pers=%20s_favsn_paypalglobal_1%3D9856380030122%7C1505841661312%3B; cookie_check=yes; login_email=LOGIN_EMAIL; INSIDE_SEARCH_PARAMS=2%3bUS%3ben_US%3bAmerica%2fLos_Angeles; navlns=0; LANG=en_US%3bUS; nMjq0zk0-yCYE_iBONIGREETTNW=Jpm8RBa7sT64hIbo8v2itdfrzX6QWIO7bstdDvYj-dzgOOwis787txlMhLTiBzIPKo7tuLE2flqqRVTd3ISWJF63NnC; dev_login_email=LOGIN_EMAIL; wwp_ClJZM3hWN6BNtpFD0LimhmC=; __login_track=SJZDNH8fctvqVf3Kf226tZyuuqtefbzza2dCsGL5wgEnnp25shrKG7LFry0 HTTP/1.x 200 OK Date: Wed, 09 Apr 2008 05:21:31 GMT Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a mod_fastcgi/2.4.2 PHP/4.3.2 Cache-Control: private Expires: Thu, 05 Jan 1995 22:00:00 GMT Pragma: no-cache Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 ---------------------------------------------------------- https://developer.paypal.com/cgi-bin/devscr?cmd=_login-done&login_access=0 GET /cgi-bin/devscr?cmd=_login-done&login_access=0 HTTP/1.1 Host: developer.paypal.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0 Cookie: homepage=3; upct=24; KHcl0EuY7AKSMgfvHl7J5E7hPtK=bFrgcM30Gb-2b3E85K4SiHyEzsMZeRVIqxjlur44o74QGXZnvTnHGme_QggT-eQFT34cVqPLl1OhGdE_; cookie_srd_optin=true; s_pers=%20s_favsn_paypalglobal_1%3D9856380030122%7C1505841661312%3B; cookie_check=yes; login_email=LOGIN_EMAIL; INSIDE_SEARCH_PARAMS=2%3bUS%3ben_US%3bAmerica%2fLos_Angeles; navlns=0; LANG=en_US%3bUS; nMjq0zk0-yCYE_iBONIGREETTNW=Jpm8RBa7sT64hIbo8v2itdfrzX6QWIO7bstdDvYj-dzgOOwis787txlMhLTiBzIPKo7tuLE2flqqRVTd3ISWJF63NnC; dev_login_email=LOGIN_EMAIL; wwp_ClJZM3hWN6BNtpFD0LimhmC=; __login_track=SJZDNH8fctvqVf3Kf226tZyuuqtefbzza2dCsGL5wgEnnp25shrKG7LFry0 HTTP/1.x 200 OK Date: Wed, 09 Apr 2008 05:21:33 GMT Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a mod_fastcgi/2.4.2 PHP/4.3.2 Cache-Control: must-revalidate, proxy-revalidate, no-cache Set-Cookie: nMjq0zk0-yCYE_iBONIGREETTNW=8qM5LB9CpXGBE5a_I5Rhcbxm4Gh5sb9jkHZIp48LnFbNJ_aBcwM3cLz6hMWmXxvggy0dck9TI_dy2xGNAa9b_KE9Nme; expires=Sat, 06-Sep-2008 05:21:34 GMT; path=/; domain=.paypal.com Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 ---------------------------------------------------------- So based off that and trying to go off this sample I've got the following: <?php include_once("../includes/Functions.php"); $PayPalDevUsername = "LOGIN_EMAIL"; $PayPalDevPassword = "LOGIN_PASSWORD"; $PayPalDevLoginURL = "https://developer.paypal.com/cgi-bin/devscr?__track=_home:login/main:_login-submit"; $PayPalDevLoginCredentials = "cmd=_login-submit&login_cmd=&login_params=&login_email=" . $PayPalDevUsername . "&login_password=" . $PayPalDevPassword . "&submit=Log+In"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($ch, CURLOPT_URL, $PayPalDevLoginURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_REFERER, "https://developer.paypal.com/devscr?cmd=_logout"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $PayPalDevLoginCredentials); $res = curl_exec($ch); curl_close($ch); $PayPalDevLoginURL = "https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($ch, CURLOPT_URL, $PayPalDevLoginURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_REFERER, "https://developer.paypal.com/devscr?cmd=_logout"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, ""); $res = curl_exec($ch); curl_close($ch); $PayPalDevLoginURL = "https://developer.paypal.com/cgi-bin/devscr?cmd=_login-done&login_access=0"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($ch, CURLOPT_URL, $PayPalDevLoginURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_REFERER, "Referer: https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, ""); $res = curl_exec($ch); curl_close($ch); ?> When I run that I get a blank white page and I still can't access the PayPal sandbox. Any ideas?? Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512673 Share on other sites More sharing options...
discomatt Posted April 9, 2008 Share Posted April 9, 2008 Paypal might intentionally block attempts to login like this. Beyond that, I'm not sure. I tend to avoid interfacing with other code without an API Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512681 Share on other sites More sharing options...
darkfreaks Posted April 9, 2008 Share Posted April 9, 2008 <?php ini_set('error_reporting',E_ALL);?> tell us what errors you get then Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512691 Share on other sites More sharing options...
angelleye Posted April 9, 2008 Author Share Posted April 9, 2008 This is running on my test server and I've already got that set to show all. I'm not getting any errors or warnings. Quote Link to comment https://forums.phpfreaks.com/topic/100240-how-to-sign-in-to-a-3rd-party-web-site-from-within-a-php-script/#findComment-512697 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.