Topic-icon Initialize FB Client in Custom Component

Active Subscriptions:

None
12 years 5 months ago #39994 by Ivan
In My Component, When I wanted to check if the user is Logged into FB I used to add
 $jfbcLibraryFile = JPATH_ROOT.DS.'components'.DS.'com_jfbconnect'.DS.'libraries'.DS.'facebook.php';
    if (!JFile::exists($jfbcLibraryFile)) {
     echo "JFBConnect not found. Please reinstall.";
     return;
    }
    require_once ($jfbcLibraryFile);

and then add :
$fbClient = JFBConnectFacebookLibrary::getInstance();

$fbUserId = $fbClient->getFbUserId();





To get the logged in user id.


I see there is
// Deprecated file. Shouldn't need to require/include this file, but if you are, please load
require_once(JPATH_SITE . '/components/com_jfbconnect/libraries/provider/facebook.php');


And in the fb provider there is
    function getFbClient()
    {
        JLog::add("JFBConnectFacebookLibrary getFbClient is deprecated. Use JFBCFactory::provider('facebook')->client", JLog::WARNING, 'deprecated');
        return $this->client;
    }


How would I go about initializing Fb to get the logged in FB user id in my component.
The topic has been locked.
Support Specialist
12 years 5 months ago #39999 by alzander
Just use the following code:
$fbLibrary = JFBCFactory::provider('facebook');
You don't need to do any requires or anything else. That's the new way as of JFBConnect v5.1 to get the provider library file for any of the social networks we support.

I hope that helps,
Alex
The topic has been locked.