ZenCart facebook 登陆

这几天为我的网站开发了一个zen cart插件,目的是为了方便用户在购买的时候不需要用户直接在网站上注册,只需要有一个facebook帐户即可登录。大家可以访问http://www.batterylaptops.co.uk 看下效果,下面我详细介绍下这个插件的安装过程。

首先打开http://www.facebook.com/developers/apps.php 注册网站的apps,注册成功以后记住“appId” 和”secret”, 这在后面需要用到。

首先到 这里下载zen cart 的facebook插件:

下面是详细的安装步骤:

1.  备份”includes/modules/pages/login/header_php.php”, “includes/modules/pages/logoff/header_php.php”, 这两个文件需要覆盖到之前系统的,所以建议安装插件之前最好先备份。

2.  导入SQL文件”install_sql.sql”。

3. 上传所有文件到服务器中。

4. 编辑登录模板页面”tpl_login_default.php”,添加下面代码在页面空白中

<div id=”fb-root”></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId   : ‘<?php echo $facebook->getAppId(); ?>’,
session : <?php echo json_encode($session); ?>, // don’t refetch the session when PHP already has it
status  : true, // check login status
cookie  : true, // enable cookies to allow the server to access the session
xfbml   : true // parse XFBML
});

// whenever the user logs in, we refresh the page
FB.Event.subscribe(‘auth.login’, function() {
window.location = “<?php echo zen_href_link(‘facebook’, ”, ‘SSL’); ?>”
});
};

(function() {
var e = document.createElement(‘script’);
e.src = document.location.protocol + ‘//connect.facebook.net/en_US/all.js’;
e.async = true;
document.getElementById(‘fb-root’).appendChild(e);
}());
</script>
<div>Have a Facebook account? <fb:login-button perms=”email”></fb:login-button></div>

5. 最后编辑”includes/extra_configures/facebook-config.php” , 替换 “appId” 和 “secret” 字段.

所有步骤完成以后,打开登录页面譬如http://www.batterylaptops.co.uk/index.php?main_page=login 即可以看到facebook的登录按钮。

来自:http://seo.shopokey.com/2011/04/facebook-fconnect-zen-cart-%E6%8F%92%E4%BB%B6/

猜你喜欢

转载自whoiswhoiswho.iteye.com/blog/1561383