Difference between revisions of "FBC on sites with multiple domains"

Line 1: Line 1:
Some websites have a couple of domains pointing to the same Joomla system. Facebook App in www.facebook.com/developers however only allow you to associate one domain for each Application Secret and API Key.
+
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 remedy this issue, first you will have to create three separate FB Apps in Facebook Developers area (or more, according to your requirement).
+
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 please open up <br />
+
Then open:<br /><br/>
 
'''For JomSocial 2.4''' components\com_community\libraries\core.php, Line 846 <br />
 
'''For JomSocial 2.4''' components\com_community\libraries\core.php, Line 846 <br />
 
'''For JomSocial 2.8:''' components\com_community\libraries\core.php, Line 1147.  
 
'''For JomSocial 2.8:''' components\com_community\libraries\core.php, Line 1147.  
 
+
Locate:<br/><br/> <syntaxhighlight lang="php">
<syntaxhighlight lang="php">
+
 
$value = $this->_jparam->get($key, $default, $group);
 
$value = $this->_jparam->get($key, $default, $group);
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<br />
 
<br />
Modify it to be
+
Modify it as follows:<br/><br/>
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
 
       if ($key == 'fbconnectkey' || $key == 'fbconnectsecret')
 
       if ($key == 'fbconnectkey' || $key == 'fbconnectsecret')
Line 34: Line 33:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<br />
 
<br />
You are now good to go!
+
<font color=cornflowerblue>You are now good to go!</font>
  
 
'''Credit:''' Adam Lin (JomSocial Developer)
 
'''Credit:''' Adam Lin (JomSocial Developer)

Revision as of 17:38, 7 March 2013

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)