$jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
$fbUserId = $jfbcLibrary->getFbUserId(); // Get the Facebook ID of the user
$profileLibrary = JFBConnectProfileLibrary::getInstance();
$profile = $profileLibrary->fetchProfile($fbUserId, array(0 => 'first_name', 1 => 'last_name'));
$firstName = $profile->get('first_name'); // this gets the first name of the user.
public function onBeforeAkeebasubsControllerLevelRead(FOFController &$controller, FOFInput &$input)
{
// instance JFBC class
$jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
$fbUserId = $jfbcLibrary->getFbUserId(); // Get the Facebook ID of the user
$profileLibrary = JFBConnectProfileLibrary::getInstance();
$profile = $profileLibrary->fetchProfile($fbUserId, array(0 => 'first_name', 1 => 'last_name', 2 => 'name', 3 => 'email'));
// Get the akeebasubs view object
$view = $controller->getThisView();
// print_r($view); // to see the elements/properties ($view->cache is what you'll be most interested in)
// array to push facebook data into
$cache = array();
$cache['email'] = $profile->get('email'); // where $profile is your FB profile object
/* ... any other FB data here ... */
$cache['name'] = $profile->get('name');
// Overwrite the elements of $view->cache (that you want to populate with FB data - E.G. in a loop
$overwriteKeys = array_keys($cache); // the array keys we'll want to overwrite in the $view->cache
foreach($view->cache as $k => $v){
// if the key ($k) is one that we're populating with data from FB
if(in_array($k, $overwriteKeys)){
// set the matched element within $view->cache to the data from $cache array
$view->cache[$k] = $cache[$k]; // E.G. $view->cache['email'] = $cache['email'];
} //end if
}//end foreach
}
Join our newsletter to get alerts for Joomla releases, tips and tricks and extension updates.