herghost Posted August 5, 2012 Share Posted August 5, 2012 Hi Guys I am trying to implement the rpxnow / janrain social login into my site. I am having issues in returning the providername when the user logs in with facebook. Basically the results from janrain are returned as an array. to get the providerid from Google I use this: foreach ($auth_info as $key) { } $provider = $key['providerName']; which correctly returns "Google", however when the user try's to login with facebook the result is "f" where the array output is "Facebook". Using the demo file for outputting the array, the structure looks like this for google: auth_info: array(2) { ["stat"]=> string(2) "ok" ["profile"]=> array(10) { ["url"]=> string(45) "https://plus.google.com/*deleted*" ["preferredUsername"]=> string(10) "*deleted*" ["email"]=> string(20) "*deleted*" ["name"]=> array(3) { ["givenName"]=> string(4) "Dave" ["familyName"]=> string(4) "*deleted*" ["formatted"]=> string(9) "*deleted*" } ["photo"]=> string(169) "http://www.google.com/ig/c/photos/public/*deleted*" ["displayName"]=> string(9) "*deleted*" ["identifier"]=> string(53) "https://www.google.com/profiles/*deleted*" ["verifiedEmail"]=> string(20) "*deleted*" ["providerName"]=> string(6) "Google" ["googleUserId"]=> string(21) "*deleted*" } } and like this for facebook auth_info: array(3) { ["stat"]=> string(2) "ok" ["profile"]=> array(12) { ["providerName"]=> string( "Facebook" ["identifier"]=> string(48) "http://www.facebook.com/profile.php?id=*deleted*" ["preferredUsername"]=> string( "*deleted*" ["displayName"]=> string(9) "*deleted*" ["email"]=> string(20) "*deleted*" ["name"]=> array(3) { ["formatted"]=> string(9) "*deleted*" ["givenName"]=> string(4) "Dave" ["familyName"]=> string(4) "*deleted*" } ["url"]=> string(33) "http://www.facebook.com/*deleted*" ["photo"]=> string(55) "https://graph.facebook.com/*deleted*/picture?type=large" ["utcOffset"]=> string(5) "01:00" ["address"]=> array(2) { ["formatted"]=> string(16) "*deleted*" ["type"]=> string(15) "currentLocation" } ["gender"]=> string(4) "male" ["verifiedEmail"]=> string(20) "*deleted*" } ["limited_data"]=> string(5) "false" } I also tried to use $provider = ['profile']['providerName'] however this returns an error : PHP Fatal error: Cannot use string offset as an array How can I correctly return "Facebook" Thanks Quote Link to comment https://forums.phpfreaks.com/topic/266698-jainrain-social-login-error-in-returning-provider-name/ 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.