Topic-icon Authenticated Referral for single joomla page

Active Subscriptions:

None
11 years 1 month ago #52993 by simcro
Is it possible to have users who are referred by facebook (through Page Tab) to be automatically logged in just for one page, not the whole site.

The context is that we have a full site, one page of which acts as the facebook interface for a multiplayer game. The game is also used on other pages by users who have logged in / registered in the normal way through the site and the game uses the joomla database. Is there any way of triggering an authenticated referral, either registration or login, just from that 1 page?
The topic has been locked.
Support Specialist
11 years 1 month ago #53000 by alzander
"Authenticated Referrals", the feature from Facebook where a user can be referred to your site and automatically logged in, were removed back in 2013. I'm assuming you're just trying to accomplish something similar. If so, can you tell me how you're detecting the user came from Facebook on that one page? My guess is that you should be able to add a little bit of Javascript to that specific page and, when a user is coming from Facebook, add a call to:
jfbc.login.provider('facebook')
That will put up the permissions prompt for new users or automatically login users that have authenticated to your site before.

I hope that helps, but if not, again, explain some more.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 1 month ago #53004 by simcro
I have tried that and I am getting a javascript error. Uncaught ReferenceError: FB is not defined from line 42 of the .js
$user = JFactory::getUser();
if($user->guest) {
	echo"<script type=\"text/javascript\"> jfbc.login.provider('facebook') </script>";
} else {
//invoke game when logged in (users are referred back to same page after login)
}
The topic has been locked.
Support Specialist
11 years 1 month ago #53012 by alzander
That code looks correct, but it's probably happening right as the page is loaded, before the Facebook library is fully initialized. Try updating it to:
jfbcJQuery(document).ready(function () {
  jfbc.login.provider('facebook');
}
That has a much better chance of working, but there's also another way (though more complicated) to ensure their library has fully loaded first.

Try that and let us know how it goes and hopefully that's all you'll need.

Thanks,
Alex
The topic has been locked.