ecshop qq互联登录OAuth2.0
生活随笔
收集整理的這篇文章主要介紹了
ecshop qq互联登录OAuth2.0
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
下載最新的sdk
http://wiki.open.qq.com/wiki/website/SDK%E4%B8%8B%E8%BD%BD
然后我把最新的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'], '#" onClick="Hongru.box.open(document.getElementById(\'dengludiv\').innerHTML,{isBar:0,width:0,height:0})" ', '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();}}轉載自:http://www.9958.pw/post/ecshop_oauth2
總結
以上是生活随笔為你收集整理的ecshop qq互联登录OAuth2.0的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 递归神经网络结构形式,RNN神经网络基本
- 下一篇: html页面实现自动刷新或自动跳转