FBC on sites with multiple domains

Some websites have a couple of domains running off of the same Joomla installation. Facebook App in www.facebook.com/developers however only allows you to associate one domain for each Application Secret and API Key.

To fix this issue, you will first have to create three separate FB Apps in the Facebook Developers Area (possibly more, depending on your requirements).

Then open:

  • For JomSocial 2.4 components\com_community\libraries\core.php, Line 846
  • For JomSocial 2.8: components\com_community\libraries\core.php, Line 1147.

Locate:

$value = $this->_jparam->get($key, $default, $group);


Modify it as follows:

       if ($key == 'fbconnectkey' || $key == 'fbconnectsecret')
        {
            $url = new JURI(JURI::base());
            $urlDomain = $url->toString(array('scheme', 'host'));
 
            switch ($urlDomain) {
                case 'http://www.myfirstdomain.com':
                    return ($key == 'fbconnectkey') ? '14myAPIkey60' : '7d142myapplicationsecretde0fb0';
                    break;
                case 'http://www.myseconddomain.com':
                    return ($key == 'fbconnectkey') ? '14myAPIkey60' : '7d142myapplicationsecretde0fb0';
                    break;
                case 'http://www.mythirddomain.com':
                    return ($key == 'fbconnectkey') ? '14myAPIkey60' : '7d142myapplicationsecretde0fb0';
                    break;
            }
        }
 
        $value = $this->_jparam->get($key, $default, $group);


You are now good to go!

Credit: Adam Lin (JomSocial Developer)