当前位置:网站首页>Third party login initial version
Third party login initial version
2022-07-04 03:20:00 【Ma nongnong tattooed with Guan Ye】
1. Go to QQ Internet platform download SDK
QQ Internet platform website :QQ Homepage of Internet official website
2. stay public Create under directory plugins Catalog ( Configure according to the applied domain name ), And then qq Of SDK Put in

3. visit domain name /plugins/qq/index.php Configure the configuration item
APP ID :101542020
APP Key :539cd4f7784f107fa74ad58d87b5c916
token url callback: Home address example :http://www.tpshop.com/index.php/home/login/qqcallback
Be careful : It has to be tpshop Because of the requirements of filing
4. stay home modular Login Added to controller qqcallback() Method
/**
* Third party login
* @return \think\response\Redirect
*/
public function qqcallback(){
require_once('./plugins/qq/API/qqConnectAPI.php');
$qc = new \QC();
# obtain access_token
$access_token = $qc->qq_callback();
echo $access_token;
echo '<br>';
# obtain openid
$openid = $qc->get_openid();
echo $openid;
echo '<br>';
$qc = new \QC($access_token,$openid);
// dd($qc->get_user_info());
# Get user information
$user_info = $qc->get_user_info();
# Business logic layer adds warehousing
User::createUser($user_info,$openid);
# Jump page
return redirect('../index');
}
The business logic layer performs warehousing operations , With openid Judge whether the library exists
/**
* Third party login
* @param $user_info
* @param $openid
* @return bool
* @throws DbException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function createUser($user_info,$openid){
# Judge whether there is one in the Library open_id
$is_user_info = \app\common\model\User::where('openid',$openid)->find();
if ($is_user_info){
session('user_info',$is_user_info);
}else{
# Newly added data
$user_info = \app\common\model\User::create([
'username'=>'',
'nickname'=>$user_info['nickname'],
'phone'=>0,
'password'=>lodermd5(123456),
'figure_url'=>$user_info['figureurl'],
'email'=>'',
'open_type'=>'qq',
'openid'=>$openid
]);
session('user_info',$user_info->toArray());
}
return true;
}
Please refer to
qq/API/qqConnectAPI.php
qq/example/oauth/index.php
Last modified view/login/login.html Of a Tab to jump
Path is :
<a href="/plugins/qq/example/oauth/index.php">
<img src="../img/qq.png" width="35px" height="35px" />
</a>————————————————
Copyright notice : This paper is about CSDN Blogger 「Doc_ACwhite」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/Doc_ACwhite/article/details/122837783
边栏推荐
- National standard gb28181 protocol platform easygbs fails to start after replacing MySQL database. How to deal with it?
- 長文綜述:大腦中的熵、自由能、對稱性和動力學
- The property of judging odd or even numbers about XOR.
- Redis transaction
- No clue about the data analysis report? After reading this introduction of smartbi, you will understand!
- Crawler practice website image batch download
- Talking about custom conditions and handling errors in MySQL Foundation
- ZABBIX API batch delete a template of the host
- Eh, the log time of MySQL server is less than 8h?
- [latex] production of complex tables: excel2latex and detail adjustment
猜你喜欢
![Backpropagation formula derivation [Li Hongyi deep learning version]](/img/ef/f76eae39c4f8716a0030a60c85b09c.gif)
Backpropagation formula derivation [Li Hongyi deep learning version]

A brief talk on professional modeler: the prospect and professional development of 3D game modeling industry in China

Tsinghua University product: penalty gradient norm improves generalization of deep learning model
![Stm32bug [the project references devices, files or libraries that are not installed appear in keilmdk]](/img/0d/7a8370d153a8479b706377c3487220.jpg)
Stm32bug [the project references devices, files or libraries that are not installed appear in keilmdk]

GUI Graphical user interface programming (XIV) optionmenu - what do you want your girlfriend to wear on Valentine's day

New year's first race, submit bug reward more!

WP collection plug-in free WordPress collection hang up plug-in

Problems and solutions of several concurrent scenarios of redis

PID of sunflower classic

MySQL query
随机推荐
Day05 錶格
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
Pagoda SSL can't be accessed? 443 port occupied? resolvent
Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
The "two-way link" of pushing messages helps app quickly realize two-way communication capability
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
How to pipe several commands in Go?
What are the virtual machine software? What are their respective functions?
Network communication basic kit -- IPv4 socket structure
Node write API
Buuctf QR code
Www 2022 | taxoenrich: self supervised taxonomy complemented by Structural Semantics
Setting methods, usage methods and common usage scenarios of environment variables in postman
Contest3145 - the 37th game of 2021 freshman individual training match_ D: Ranking
Global and Chinese market of digital impression system 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL workbench use
Dare to climb here, you're not far from prison, reptile reverse actual combat case
AI 助力藝術設計抄襲檢索新突破!劉芳教授團隊論文被多媒體頂級會議ACM MM錄用
Jenkins continuous integration environment construction V (Jenkins common construction triggers)
I stepped on a foundation pit today