Home >PHP Framework >Workerman >Method to implement web scanning login based on Workerman

Method to implement web scanning login based on Workerman

藏色散人
藏色散人forward
2020-03-13 13:51:043872browse

Web scan code login implementation

Based on Workerman, I made a scan code login example for reference by friends in need. If you find any problems, please correct them.

Implementation flow chart

Method to implement web scanning login based on Workerman

Running process

①: User A visits WeChat In the web version, the WeChat server generates a globally unique ID for this session. obsbQ-Dzag== in the above URL is this ID. At this time, the system does not know who the visitor is.

②: User A opens WeChat on his mobile phone and scans the QR code, and prompts the user to confirm login.

③: WeChat on the phone is logged in. After the user clicks to confirm login, the WeChat client on the phone submits the WeChat account and the scanned ID to the server

④: Server Bind this ID to user A's WeChat ID and notify the web version of WeChat that the WeChat ID corresponding to this ID is user A. The web version of WeChat loads user A's WeChat information. At this point, the entire process of scanning the QR code to log in is completed.

Scanning QR code to log in looks magical, mainly because scanning its own code on WeChat APP will do some additional operations that ordinary QR code software cannot do, that is, combining the currently logged-in WeChat and the scanned one The ID is submitted to the WeChat server. Similar applications also have functions such as scanning the QR code to pay, scanning the QR code to add a public account, etc.

The above content comes from the Internet.

Description

Written based on the workerman/gateway framework. The web service can also be replaced by apache and nginx. I use the code scanning tool instead of scanning the code with my mobile phone. You can also directly obtain a URL and put it in another browser window to simulate the process of scanning the QR code. The production environment must be scanned using the app.

Get the sample source code

https://github.com/wanglelecc/workerman-qrcode-login-for-win

Run the sample (Win)

Double-click login_start_for_win.bat under windows to

put 1 Preview picture:

Method to implement web scanning login based on Workerman

# Note: This is just an example to give you an idea. In actual use, there is still a lot of room for improvement.

The above is the detailed content of Method to implement web scanning login based on Workerman. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete