Topic-icon Detecting Facebook login

Active Subscriptions:

None
10 years 7 months ago #36363 by paz
Detecting Facebook login was created by paz
Greetings Alex,

I found this code on one of the developers pages:

require_once JPATH_ROOT.DS.'components'.DS.'com_jfbconnect'.DS.'libraries'.DS.'facebook.php';
$jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
$post = 'is doing something';
$post = 'www.sourcecoast.com/jfbconnect';
if ($jfbcLibrary->getUserId()) // Check if there is a Facebook user logged in
$jfbcLibrary->setFacebookMessage($post);


Running the code works fine up till:
if ($jfbcLibrary->getUserId()) // Check if there is a Facebook user logged in

I'm rendering this on the K2 item.php template. At which point I get 500.

Is this correct code? Is there a proper reference somewhere to understand how the JFBConnect object works?

I want to merely check to see if a logged in user is connected via facebook link or something else.

Thanks,
p.
The topic has been locked.
Support Specialist
10 years 7 months ago #36382 by alzander
Replied by alzander on topic Detecting Facebook login
Paul,
That documentation is a bit out of date, especially with the new v5.1 release. We're honestly a bit behind on some of our documentation, something that will be a focus for us to fix throughout September.

Anyways, the easy fix is to update that line is failing with:
if (JFBCFactory::provider('facebook')->getMappedUserId())
That works for 'facebook' and 'google', actually and will return the actual Facebook user id of the user.. You can use the if statement just to check if they've connected their account to Facebook though.

You don't need *any* of the other code you mentioned to perform that check, just so you know.

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

None
10 years 7 months ago #36436 by paz
Replied by paz on topic Detecting Facebook login
Thanks as always Alex!

That code worked like a charm!! I was getting irritated on having error messages being shown when not logged in at all, so this is perfect.

Cheers,
p.
The topic has been locked.
Support Specialist
10 years 7 months ago #36439 by alzander
Replied by alzander on topic Detecting Facebook login
No problem. Definitely test in different configurations, like:
* Logged in with Facebook
* Logged into Joomla with an account that has connected their account to Facebook, but isn't currently logged into Facebook
* With a Joomla-only account

I think it should work in all those cases, but just want to make sure you cover your bases.

Thanks,
Alex
The topic has been locked.