下載最新的sdkphp
http://wiki.open.qq.com/wiki/website/SDK%E4%B8%8B%E8%BD%BDweb
而後我把最新的sdk文檔裏面的有用的程序包直接上傳進了 /api/裏面而後 分別登錄 處理 、返回文件 分別寫在了 qqlogin.php 文件裏面 目錄結構注意看下面的程序require部分。sql
<?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(); } }