简体   繁体   English

如何在Drupal多站点中管理Facebook连接?

[英]How to manage Facebook connect in Drupal multisite?

I have a Drupal multisite installation. 我有一个Drupal多站点安装。 It is not a common multisite installation. 这不是常见的多站点安装。 Long story short: I have one single database, one single setting.php and the change of theme is managed according to the site domain by the module ThemeKey. 长话短说:我有一个单一的数据库,一个单一的setting.php,主题的更改由模块ThemeKey根据站点域进行管理。 The drupal installation makes two sites working with different themes and i managed to have for them two different domains using Apache Server Alias, so that i have two sites www.foo.com and www.bar.com. drupal安装使两个站点使用不同的主题,并且我使用Apache Server Alias设法为它们拥有两个不同的域,因此我有两个站点www.foo.com和www.bar.com。

Now i'm managing the facebook registration with the module FBOauth that allows to enter only one facebook app id. 现在,我正在使用模块FBOauth管理Facebook注册,该模块仅允许输入一个Facebook应用ID。 In the first site, let's say www.foo.com, facebook registration works perfectly for it is connected with the facebook app which fboauth knows about. 在第一个站点,例如www.foo.com,facebook注册非常有效,因为它与fboauth知道的facebook应用程序连接。 In the second site, www.bar.com, the registration doesn't work for facebook allows me to add, to a single facebook app, only one domain (or subdomain of it, that's not the case). 在第二个网站www.bar.com上,facebook的注册无效,这使我只能将一个域(或它的子域,不是这种情况)添加到单个facebook应用中。 I mean, in the facebook app i can enter www.foo.com, but not www.bar.com, so if i try to register from www.bar.com facebook throws a 'domain not allowed' error. 我的意思是,在Facebook应用程序中,我可以输入www.foo.com,但不能输入www.bar.com,因此,如果我尝试从www.bar.com注册,facebook会抛出“不允许使用域名”错误。

I think the correct way to deal with this is by opening a second facebook app for www.bar.com, but fbaouth allows me to enter only one app id. 我认为解决此问题的正确方法是为www.bar.com打开第二个Facebook应用程序,但是fbaouth允许我仅输入一个应用程序ID。 How can i overcome this? 我该如何克服呢?

EDIT: there are two variables fboauth_id and fboauth_secret. 编辑:有两个变量fboauth_id和fboauth_secret。 Overriding these solves the problem, but i can't do it in setting.php, there's another way? 覆盖这些可以解决问题,但是我无法在setting.php中做到,还有另一种方法吗?

RAW SOLUTION: I solved the problem, modifying fboauth module code. RAW解决方案:我解决了该问题,修改了fboauth模块代码。 I created two functions: one returning an app id, another returning an app secret, depending on the domain i'm in. Then I substituted every "variable_get('fboauth_id', '')" and "variable_get('fboauth_secret', '')" in the module files with my customized functions. 我创建了两个函数:一个函数返回一个应用程序ID,另一个函数返回一个应用程序密码,具体取决于我所在的域。然后我替换了每个“ variable_get('fboauth_id','')”和“ variable_get('fboauth_secret','带有我自定义功能的模块文件中的')“。 It is not elegant, and i'm still interested in better solutions. 它并不优雅,我仍然对更好的解决方案感兴趣。

function fboauth_get_app_id_depending_on_domain(){
  $server_name = ($_SERVER['SERVER_NAME']);
  $server_uri =($_SERVER['REQUEST_URI']); 
  if($server_name=='www.bar.com'){
     $app_id='1234567890';
  }else{
     $app_id=variable_get('fboauth_id', '');
  }
 return $app_id;
}

function fboauth_get_app_secret_depending_on_domain(){
 $server_name = ($_SERVER['SERVER_NAME']);
 $server_uri =($_SERVER['REQUEST_URI']); 
 if($server_name=='www.bar.com'){
      $app_secret='1234567890';
 }else{
     $app_secret=variable_get('fboauth_secret', '');
 }
 return $app_secret;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM