当前位置:网站首页>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
边栏推荐
- Handler source code analysis
- Have you entered the workplace since the first 00???
- Eh, the log time of MySQL server is less than 8h?
- Want to do something in production? Then try these redis commands
- Formulaire day05
- Is online futures account opening safe and reliable? Which domestic futures company is better?
- [source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
- Easy to win insert sort
- Hospital network planning and design document based on GLBP protocol + application form + task statement + opening report + interim examination + literature review + PPT + weekly progress + network to
- Basé sur... Netcore Development blog Project Starblog - (14) Implementation of theme switching function
猜你喜欢

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

Package and download 10 sets of Apple CMS templates / download the source code of Apple CMS video and film website

The difference between MCU serial communication and parallel communication and the understanding of UART

Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)

Dare to climb here, you're not far from prison, reptile reverse actual combat case

Buuctf QR code

Hospital network planning and design document based on GLBP protocol + application form + task statement + opening report + interim examination + literature review + PPT + weekly progress + network to

Record a problem that soft deletion fails due to warehouse level error

Teach you how to optimize SQL

Jenkins configures IP address access
随机推荐
Jenkins configures IP address access
Database concept and installation
@Scheduled scheduled tasks
MySQL is dirty
Unity knapsack system (code to center and exchange items)
Amélioration de l'efficacité de la requête 10 fois! 3 solutions d'optimisation pour résoudre le problème de pagination profonde MySQL
New year's first race, submit bug reward more!
National standard gb28181 protocol platform easygbs fails to start after replacing MySQL database. How to deal with it?
Package and download 10 sets of Apple CMS templates / download the source code of Apple CMS video and film website
What are the virtual machine software? What are their respective functions?
Jenkins continuous integration environment construction V (Jenkins common construction triggers)
Résumé des outils communs et des points techniques de l'examen PMP
Stm32bug [the project references devices, files or libraries that are not installed appear in keilmdk]
The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
MySQL backup notes
Love and self-discipline and strive to live a core life
How much does it cost to open a futures account in China? Where is it safe to open an account at present?
Formulaire day05
Pagoda SSL can't be accessed? 443 port occupied? resolvent
2022 Guangxi provincial safety officer a certificate examination materials and Guangxi provincial safety officer a certificate simulation test questions