广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > Ecshop微博登录形式与用户账号的绑定

二次开发Ecshop二次开发

二次开发Ecshop二次开发

Ecshop微博登录形式与用户账号的绑定

 Ecshop微博登录方式与用户账号的绑定
1.在ecs_users表中添加字段uid。
2.在includes中的lib_passport.php中的
$other_key_array = array('msn', 'qq', 'office_phone','home_phone', 'mobile_phone');
添加一字段'uid',即:
$other_key_array = array('uid','msn', 'qq','office_phone', 'home_phone','mobile_phone');
3.在user.php的
$username =isset($_POST['username']) ? trim($_POST['username']) :'';
$password =isset($_POST['password']) ? trim($_POST['password']) :'';
$email = isset($_POST['email']) ? trim($_POST['email']): '';
后面添加
$other['uid'] = isset($_SESSION['uid']) ?$_SESSION['uid'] : '';
5.将微博插件中自带的callback.php代码全都替换成下面代码:
session_start();
define('IN_ECS',true);
require('../includes/init.php');
//include_once('../includes/b_transaction.php');
//include_once('../includes/b_passport.php');
include_once( 'config.php');
include_once('saetv2.ex.class.php' );
$o = new SaeTOAuthV2( WB_AKEY, WB_SKEY );
if (isset($_REQUEST['code'])){
$keys =array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] =WB_CALLBACK_URL;
try{
$token =$o->getAccessToken( 'code', $keys );
//通过token获取到用户信息
} catch(OAuthException $e) {
}
}
if ($token) {
$_SESSION['token'] = $token;
$c = newSaeTClientV2( WB_AKEY , WB_SKEY ,$_SESSION['token']['access_token']);
$ms=$c->home_timeline(); //done
$uid_get =$c->get_uid();
//$uid =$uid_get['uid'];
//echo$uid;die;
$sql ="SELECT * "." FROM " .$GLOBALS['ecs']->table("users")." WHEREuid='".$_SESSION["token"]["uid"]."'";
$_SESSION["uid"]=$_SESSION["token"]["uid"];
$row =$GLOBALS['db']->getRow($sql);
//var_dump($row);die;
if($row){
$GLOBALS['user']->set_session($row["user_name"]);
$GLOBALS['user']->set_cookie($row["user_name"]);
header("Location:../user.php\n");
//验证成功,跳转页面
exit;
}else{
$_SESSION["user_id"] = $row[0]["user_id"];
header("Location:../user.php?act=register\n");
exit;
}
}