ecshop qq互联登录OAuth2.0

然后我把最新的sdk文档里面的有用的程序包直接上传进了 /api/里面然后 分别登陆 处理 、返回文件 分别写在了 qqlogin.php 文件里面 目录结构注意看下面的程序require部分。

<?php define(\'IN_ECS\', true); require(dirname(__FILE__) . \'/includes/init.php\'); require_once(ROOT_PATH . \'languages/\' .$_CFG[\'lang\']. \'/user.php\'); require(ROOT_PATH.\'api/QQConnect/API/qqConnectAPI.php\'); $user_id = $_SESSION[\'user_id\']; $action = isset($_REQUEST[\'act\']) ? trim($_REQUEST[\'act\']) : \'default\'; $qc = new Qc(); if($action == \'default\') { $qc->qq_callback(); $open_id = $qc->get_openid(); //根据 OPEN_ID 判断数据 $sql = "SELECT * FROM".$ecs->table(\'users\')." where qq_open_id = \'".$open_id."\'"; $row = $db->getRow($sql); if($row) { //曾经登陆过,存在信息 ,调用信息登录 $username = $row[\'user_name\']; $password = $row[\'user_name\']; if ($user->login($username, $password,isset($_POST[\'remember\']))) { update_user_info(); recalculate_price(); $ucdata = isset($user->ucdata)? $user->ucdata : \'\'; show_message($_LANG[\'login_success\'] . $ucdata , array($_LANG[\'back_up_page\'], $_LANG[\'profile_lnk\']), array($back_act,\'user.php\'), \'info\'); } else { show_message($_LANG[\'login_failure\'], $_LANG[\'relogin_lnk\'], \'#" \', \'error\'); } }else { //注册新用户 include_once(ROOT_PATH . \'includes/lib_passport.php\'); $username = \'qq_\'.time(); $password = \'qq_\'.time(); $email = \'qq_login\'.time().\'@qq.com\'; $other[\'qq_open_id\'] = $open_id; if (register($username, $password, $email, $other) !== false) { //$user = $qc->get_user_info(); header("Location:flow.php"); die(); } else { show_message(\'QQ登陆异常,请联系网站人员! \'); exit(); } } //处理QQ 登陆的用户的信息 }elseif($action == \'login\') { if($_SESSION[\'user_id\']>0) { show_message(\'您已经登录了! \'); header("Location:/"); }else { $qc->qq_login(); } }

转载自:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzjdpp.html