當前位置: 首頁>>代碼示例>>PHP>>正文


PHP QC::get_openid方法代碼示例

本文整理匯總了PHP中QC::get_openid方法的典型用法代碼示例。如果您正苦於以下問題:PHP QC::get_openid方法的具體用法?PHP QC::get_openid怎麽用?PHP QC::get_openid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在QC的用法示例。


在下文中一共展示了QC::get_openid方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: callback

 public function callback()
 {
     es_session::start();
     require_once APP_ROOT_PATH . "system/api_login/qqv2/qqConnectAPI.php";
     $qc = new QC();
     $access_token = $qc->qq_callback();
     $openid = $qc->get_openid();
     $use_info_keysArr = array("access_token" => $access_token, "openid" => $openid, "oauth_consumer_key" => $this->api['config']['app_key']);
     $use_info_url = "https://graph.qq.com/user/get_user_info";
     $graph_use_info_url = $qc->urlUtils->combineURL($use_info_url, $use_info_keysArr);
     $response = $qc->urlUtils->get_contents($graph_use_info_url);
     $arr = array();
     $arr = json_decode($response, true);
     $msg['field'] = 'qq_id';
     $msg['id'] = $openid;
     $msg['name'] = $arr["nickname"];
     es_session::set("api_user_info", $msg);
     $user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where qq_id = '" . $openid . "' and qq_id <> '' and is_effect=1 and is_delete=0");
     if ($user_data) {
         $user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
         $user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc");
         if ($user_current_group['score'] < $user_group['score']) {
             $user_data['group_id'] = intval($user_group['id']);
         }
         es_session::set("user_info", $user_data);
         $GLOBALS['db']->query("update " . DB_PREFIX . "user set login_ip = '" . get_client_ip() . "',login_time= " . TIME_UTC . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
         es_session::delete("api_user_info");
         app_recirect_preview();
     } else {
         $this->create_user();
         app_redirect(APP_ROOT . "/");
     }
 }
開發者ID:norain2050,項目名稱:fanwei_xindai_3.2,代碼行數:33,代碼來源:Qqv2_api.php

示例2: callback

 public function callback()
 {
     vendor('QQApi.qqConnectAPI');
     $qc = new \QC();
     $access_token = $qc->qq_callback();
     $openid = $qc->get_openid();
     $data['data'] = serialize(array('access_token' => $access_token, 'openid' => $openid));
     M('post_log')->add($data);
     //注冊會員信息
     //查看此openid是否存在
     $map['username'] = $openid;
     $detail = D('User')->where($map)->find();
     $userid = $detail['userid'];
     $nickname = $detail['nickname'];
     if (!$detail) {
         //獲取用戶信息
         $arr = $qc->get_user_info();
         M('post_log')->add(array('data' => serialize($arr)));
         $info['username'] = $openid;
         $info['nickname'] = $nickname = $arr['nickname'];
         $userid = D('User')->add($info);
     }
     if ($userid) {
         //保存session
         session('userid', $userid);
         //保存cookie用戶信息
         cookie('userid', $userid);
         cookie('nickname', $nickname);
         cookie('userid', $userid);
         redirect(U('Shenma/user'));
     }
     /* $arr = $qc->get_user_info();
     		
     		var_dump($arr);exit; */
 }
開發者ID:shenyangchong,項目名稱:bjui_php,代碼行數:35,代碼來源:OauthController.class.php

示例3: callback

 /**
  * 返回登錄
  */
 public function callback()
 {
     require_once COMMON_LIB_PATH . "QqConnect/API/qqConnectAPI.php";
     $qc = new QC();
     $callback = $qc->qq_callback();
     $openid = $qc->get_openid();
     $user = K("user")->field("uid,username,password,qqau,userlock,uuid,usergroup")->where(array("qqau" => $openid))->find();
     session("qqau", $openid);
     if (empty($user["qqau"])) {
         //首次登錄或沒有綁定賬號
         $qc = new QC($callback, $openid);
         $arr = $qc->get_user_info();
         session("UserInfo", $arr["nickname"]);
         go("Passport/Qqlogin/index");
     } elseif ($user["qqau"] == $openid) {
         //數據庫比對正確
         if ($user["userlock"] == 1) {
             $this->error("您已經被鎖定,請聯係管理員!");
         }
         //$this->eve_exp($user["uid"]);
         $loginData = array("logintime" => time(), "loginip" => ip::getClientIp(), "qqau" => $openid);
         M("user")->where(array("uid" => $user["uid"]))->save($loginData);
         // p($_POST);
         session("username", $user["username"]);
         session("uid", $user["uid"]);
         session("uuid", $user["uuid"]);
         session("usergroup", $user["usergroup"]);
         $this->success("登錄成功!正在跳轉...", U(__WEB__));
     }
 }
開發者ID:a707937337,項目名稱:proxy,代碼行數:33,代碼來源:QqloginControl.class.php

示例4: callbackAction

 public function callbackAction()
 {
     $mediaqqmodel = new Media_QQModel($this->_basemodel, $this->_qqparam);
     $app_id = isset($_REQUEST['app_id']) ? trim($_REQUEST['app_id']) : '69948denMVMoBujYGLSFGUHbkvP7E3';
     $mediaqq = $mediaqqmodel->getApp($app_id);
     $APPID = $mediaqq['APPID'] && $mediaqq['APPKEY'] ? $mediaqq['APPID'] : $mediaqq['def_APPID'];
     $APPKEY = $mediaqq['APPID'] && $mediaqq['APPKEY'] ? $mediaqq['APPKEY'] : $mediaqq['def_APPKEY'];
     $redirect_uri = $this->_qqparam['redirect_uri'] . '?app_id=' . $mediaqq['app_id'];
     $state = md5($mediaqq['app_key']);
     $qcinit = new QQAPI_YafQQConnetAPI();
     $qc = new QC();
     $access_token = $qc->qq_callback($APPID, $redirect_uri, $APPKEY);
     echo $access_token . '----------';
     $openid = $qc->get_openid($access_token);
     echo $openid . '---------';
     $qqUser = $qc->my_get_userinfo($access_token, $openid, $APPID);
     if ($qqUser && $qqUser->nickname) {
         $media_user_id = $mediaqqmodel->saveUser($openid, $qqUser, $APPID);
         if ($media_user_id) {
             $usertokentime = date('Y-m-d H:i:s', time() + Yaf_Application::app()->getConfig()->application->usertokentime);
             $login_token = $mediaqqmodel->saveAccessToken($app_id, $access_token, $openid, $media_user_id, $usertokentime);
             if ($login_token) {
                 $url = $mediaqq['token_url'];
                 $concat = '&';
                 if (strpos($url, '?') === false) {
                     $concat = '?';
                 }
                 $url .= $concat . "token={$login_token}";
                 header("Location:{$url}");
             }
         }
     }
     exit;
 }
開發者ID:pbchen,項目名稱:thirdLoginAPI,代碼行數:34,代碼來源:Qq.php

示例5: callback

 public function callback()
 {
     require 'QQ/API/qqConnectAPI.php';
     //引進qqapi 接口
     $qc = new \QC();
     $acs = $qc->qq_callback();
     //獲取access-token 和openid
     $oid = $qc->get_openid();
     $qc = new \QC($acs, $oid);
     $uinfo = $qc->get_user_info();
     //獲取用戶信息
     $user = M('user');
     $list = $user->where("openid='" . $oid . "'  and status = 1")->find();
     if ($list) {
         session('userid', $list['id']);
         session('username', $list['nickname']);
         session('userphone', $list['mobile']);
         session('userimg', $list['headpic']);
         //var_dump($list);die();
         echo "<script>window.close();window.opener.location.reload()</script>";
         exit;
         //$this->redirect('Index/index', '', 0, '頁麵跳轉中...');
     } else {
         session('openid', $oid);
         session('uinfo', $uinfo);
         session('sign', array('name' => 'QQ賬號', 'code' => 1));
         echo "<script>window.close();window.opener.location.href='" . U('User/threepartlogin') . "'</script>";
         exit;
     }
 }
開發者ID:songxiaoxiao,項目名稱:zyw,代碼行數:30,代碼來源:LoginController.class.php

示例6: qqcallback

 public function qqcallback()
 {
     Vendor('Oauth.QC#class');
     $qc = new \QC();
     $token = $qc->qq_callback();
     $openid = $qc->get_openid();
     if (!$token || !$openid) {
         $this->error('操作失敗');
     }
     // 重新實例化 QC類
     $qc = new \QC($token, $openid);
     $uinfo = $qc->get_user_info();
     $this->user_model = D('user');
     $user = $this->user_model->field('id,email,password')->where(array('qq_token' => $token, 'qq_openid' => $openid))->find();
     // echo $this->user_model->getLastSql();
     if ($user['id'] > 0) {
         // 登錄用戶
         if ($this->user_model->login($user['id'], $user['email'], $user['password'])) {
             //TODO:跳轉到登錄前頁麵
             $this->success('登錄成功!', session('rebackurl'));
         } else {
             $this->error($model->getError());
         }
     } else {
         session('avatar', $uinfo['figureurl_qq_2']);
         session('openid', $openid);
         session('token', $token);
         session('uname', $uinfo['nickname']);
         session('oatype', 'qq_');
         //print_r($uinfo);
         $this->redirect('join');
     }
 }
開發者ID:kjzwj,項目名稱:jcms,代碼行數:33,代碼來源:oauthAction.class.php

示例7: qqcallback

 public function qqcallback()
 {
     require_once "./QQ/API/qqConnectAPI.php";
     $qc = new \QC();
     echo $qc->qq_callback();
     echo $qc->get_openid();
     var_dump($qc);
 }
開發者ID:songxiaoxiao,項目名稱:zyw,代碼行數:8,代碼來源:QloginController.class.php

示例8: getAccessToken

 public function getAccessToken($parms)
 {
     require_once dirname(__FILE__) . "/API/qqConnectAPI.php";
     $qc = new QC();
     $access_token = $qc->qq_callback($this->apiId, parent::getReturnUrl(), $this->apiKey);
     $openid = $qc->get_openid();
     ISession::set('openid', $openid);
     ISession::set('access_token', $access_token);
 }
開發者ID:yongge666,項目名稱:sunupedu,代碼行數:9,代碼來源:qq.php

示例9: qq_callback

 public function qq_callback()
 {
     require_once "./public/Library/qqAuth/qqConnectAPI.php";
     $qc = new QC();
     //echo $qc->qq_callback();
     $openid = $qc->get_openid();
     $arr = $qc->get_user_info();
     $nickname = $arr["nickname"];
     //TODO 注冊登錄操作
 }
開發者ID:noikiy,項目名稱:yisheji,代碼行數:10,代碼來源:UserAction.class.php

示例10: actionQq_callback

 /**
  * QQ回調地址 
  *
  */
 public function actionQq_callback()
 {
     require_once Yii::getPathOfAlias('ext') . "/OAuth/qq/qqConnectAPI.php";
     $qc = new QC();
     $access_token = $qc->qq_callback();
     $openid = $qc->get_openid();
     $qc = new QC($access_token, $openid);
     $user_info = $qc->get_user_info();
     //查看是否已綁定
     $bind = OAuthQQ::model()->findByPk($openid);
     //數據
     $data = array('type' => 'qq', 'access_token' => $access_token, 'openid' => $openid, 'uid' => $bind ? $bind->uid : 0, 'username' => $user_info['nickname'], 'avatar' => $user_info['figureurl_2']);
     //綁定注冊
     $this->bind_register($bind, $data);
 }
開發者ID:redtreelchao,項目名稱:wander-moon,代碼行數:19,代碼來源:OAuthController.php

示例11: QQ_callback

function QQ_callback()
{
    $cb_arr = array();
    $qc = new QC();
    $access_token = $qc->qq_callback();
    //DE89B12F418C136D96F62898CBC4705E
    $openid = $qc->get_openid();
    //B8C02925F80EE3B4462B86E7868DAC1D
    //echo $access_token;
    //echo $openid;
    $qc1 = new QC($access_token, $openid);
    $userinfo_arr = $qc1->get_user_info();
    $nickname = $userinfo_arr["nickname"];
    $cb_arr = array('access_token' => $access_token, 'openid' => $openid, 'nick' => $nickname);
    return $cb_arr;
}
開發者ID:yonglinchen,項目名稱:shopping,代碼行數:16,代碼來源:callback.php

示例12: callback

 public function callback()
 {
     define('QQ_LOGIN_APPID', $this->config->get('qq_login_appid'));
     define('QQ_LOGIN_APPKEY', $this->config->get('qq_login_appkey'));
     define('QQ_CALLBACK_URI', HTTP_SERVER . 'catalog/controller/api/qq_callback.php');
     require_once DIR_SYSTEM . 'library/qq/qqConnectAPI.php';
     $qc = new QC();
     $access_token = $qc->qq_callback();
     $openid = $qc->get_openid();
     $qui = new QC($access_token, $openid);
     $user_info = $qui->get_user_info();
     $this->session->data['qq_nickname'] = $user_info['nickname'];
     $this->load->language('extension/module/qq_login');
     $data['text_qq_login'] = $this->language->get('text_qq_login');
     if (stristr($openid, 'error')) {
         echo $this->language->get('error_openid');
     } elseif ($openid) {
         $this->session->data['qq_openid'] = $openid;
         if ($this->customer->login_qq($this->session->data['qq_openid'])) {
             unset($this->session->data['guest']);
             // Default Addresses
             $this->load->model('account/address');
             if ($this->config->get('config_tax_customer') == 'payment') {
                 $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
             }
             if ($this->config->get('config_tax_customer') == 'shipping') {
                 $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
             }
             $this->response->redirect($this->url->link('account/account', '', 'SSL'));
         } else {
             $this->session->data['qq_login_warning'] = sprintf($this->language->get('text_qq_login_warning'), $this->config->get('config_name'));
             $this->response->redirect($this->url->link('account/login', '', 'SSL'));
         }
     } else {
         echo $this->language->get('text_qq_fail');
     }
 }
開發者ID:brunoxu,項目名稱:mycncart,代碼行數:37,代碼來源:qq_login.php

示例13: qq_sucsess

 public function qq_sucsess()
 {
     session_start();
     define('M_ROOT', dirname(dirname(__FILE__)));
     $ss = M_ROOT;
     $str = str_replace("\\", "/", $ss);
     include_once $str . "/API/qq/qqConnectAPI.php";
     $qc = new \QC();
     $atid = $qc->qq_callback();
     $opid = $qc->get_openid();
     $opid = (string) $opid;
     $state = I('state');
     $_SESSION['state'] = $state;
     $qc = new \QC($atid, $opid);
     // 重新帶參地new一次否則會丟失信息
     $user_model = D('yuser');
     $find = $user_model->field('uid,username,nickname,figureurl,userpic')->where(' openid=' . '"' . $opid . '"')->find();
     if (empty($find)) {
         $info = $qc->__call('get_user_info');
     }
     if (!empty($info)) {
         $data = array('username' => $info['nickname'], 'nickname' => $info['nickname'], 'sex' => $info['gender'], 'province' => $info['province'], 'city' => $info['city'], 'year' => $info['year'], 'figureurl' => $info['figureurl_qq_2'], 'openid' => $opid, 'tokenid' => $atid, 'addtime' => date('Y-m-d H:i:s'), 'loginip' => get_client_ip(), 'status' => 1);
         if ($id = $user_model->add($data)) {
             $user = $user_model->field('uid,username,figureurl,userpic')->where('uid=' . $id)->find();
             $picName = $find['userpic'];
             $picInfo = pathinfo($picName);
             $find['userpic'] = $picInfo['filename'] . '70.' . $picInfo['extension'];
             $_SESSION['user'] = $user;
             $this->redirect('/Index', '登錄成功,正在跳轉到首頁', 0);
         }
     } else {
         $picName = $find['userpic'];
         $picInfo = pathinfo($picName);
         $find['userpic'] = $picInfo['filename'] . '70.' . $picInfo['extension'];
         $qiandao = $user_model->getQiandao($find['uid']);
         $find['qiandao'] = $qiandao;
         $data = array('lastlogin' => date('Y-m-d H:i:s', time()), 'uid' => session('user.uid'));
         $user_model->save($data);
         $_SESSION['user'] = $find;
         $this->redirect('/Index', '登錄成功,正在跳轉到首頁', 0);
     }
 }
開發者ID:hehuping,項目名稱:qqyiyazhe,代碼行數:42,代碼來源:LoginController.class.php

示例14: randusname

<?php 
session_start();
function randusname($name)
{
    $nickname = $name . '_' . rand(1000, 9999);
    return $nickname;
}
require_once "../../../include/conn.php";
require_once "../../../include/myfunction.php";
require_once "../API/qqConnectAPI.php";
require_once "../../../config.inc.php";
require_once "../../../uc_client/client.php";
$siteweb = GetSiteconfig();
$qc = new QC();
$qqcallback = $qc->qq_callback();
$qqid = $qc->get_openid();
$qc = new QC($qqcallback, $qqid);
$arr = $qc->get_user_info();
if (!empty($qqcallback)) {
    $sql = "select * from user where qq_ua='{$qqid}'";
    $result = mysql_query($sql);
    $count = mysql_num_rows($result);
    $usxx = mysql_fetch_assoc($result);
    if (!empty($_SESSION['usnamese']) && !empty($usxx['qq_ua'])) {
        echo "<script>location='/u'</script>";
        exit;
    }
    if ($count) {
        if (time() > $usxx['Pingbi']) {
            $_SESSION['usnamese'] = $usxx['name'];
            $_SESSION['usidse'] = $usxx['id'];
開發者ID:kwdwkiss,項目名稱:trial,代碼行數:31,代碼來源:callback.php

示例15: index

 public function index()
 {
     //phpinfo();
     //點擊QQ登錄
     if (isset($_REQUEST['qq'])) {
         require_once "./Public/QQLogin/qqConnectAPI.php";
         $qc = new QC();
         $qc->qq_login();
         die;
     }
     //QQ登錄後返回處理
     if (isset($_REQUEST['code'])) {
         require_once "./Public/QQLogin/qqConnectAPI.php";
         $qc = new QC();
         $acs = $qc->qq_callback();
         $oid = $qc->get_openid();
         $qq_open_id = $qc->get_openid();
         echo $acs . "|" . $oid;
         $qc = new QC($acs, $oid);
         $qq_user = $qc->get_user_info();
         //p($qq_user);die;
         $username = $qq_user['nickname'];
         $sex = $qq_user['gender'] == '男' ? 1 : 0;
         $face = $qq_user['figureurl_2'];
         //頭像處理
         /*獲取網絡圖片太忙,展示考慮
             	$qq_face=$qq_user['figureurl_2'];
             	$face=date("Y_m")."/".time().".jpg";
             	$path="./Uploads/face/".date("Y_m");
             	$file="./Uploads/face/".$face;
             	//p($file);die;
             	if(!file_exists($path)){  //檢測變量中的文件夾是否存在,如果存在,刪除
         			mkdir($path,0777); //創建文件夾
         		}
             	
             	$qq_face=file_get_contents($qq_face);
             	file_put_contents($file, $qq_face);*/
         $user = M('user')->where(array('qq_open_id' => $qq_open_id))->find();
         if (!$user) {
             //第一次登錄,保存用戶信息
             $data = array('qq_open_id' => $qq_open_id, 'username' => $username, 'sex' => $sex, 'face' => $face, 'description' => $this->_post('description'), 'register_time' => time());
             //p($data);die;
             $user_id = M('user')->add($data);
             if ($user_id) {
                 session('user_id', $user_id);
                 session('username', $username);
                 redirect(U('Index/index'));
                 die;
             } else {
                 redirect(U('Index/index'));
                 die;
             }
         } else {
             //以前登錄過
             if ($user['lock'] > time()) {
                 $this->error('您已被鎖定,請過段時間在試。。。');
                 die;
             }
             session('user_id', $user['user_id']);
             session('username', $user['username']);
             redirect(U('Index/index'));
         }
         die;
     }
     if (isset($_SESSION['user_id'])) {
         redirect(U('Index/index'));
         die;
     }
     if (!$this->isPost()) {
         $this->display();
         die;
     }
     $username = $this->_post('username');
     $password = $this->_post('password', 'md5');
     $where = array('username' => $username);
     $user = M('user')->where($where)->find();
     p($username);
     p($password);
     //p($user);die;
     if ($user['lock'] == 1) {
         $this->error("您已被鎖定,請過段時間在試。。。");
     }
     if (!$user || $user['password'] != $password) {
         $this->error("用戶名或者密碼錯誤!~_~");
     }
     session('user_id', $user['user_id']);
     session('username', $user['username']);
     redirect(__APP__);
 }
開發者ID:luojiangtao,項目名稱:putishui,代碼行數:89,代碼來源:LoginAction.class.php


注:本文中的QC::get_openid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。