Ecshop微博登录形式与用户账号的绑定
发布时间: 2013-09-26 10:32:35 作者: rapoo
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"]);