Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example Analysis of the Wechat Web Landing Authorization of the Wechat Public platform of php version

2024-05-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)12/25 Report--

This article mainly shows you the "php version of Wechat public platform Wechat web login authorization example analysis", the content is easy to understand, well-organized, I hope to help you resolve your doubts, the following let the editor lead you to study and study "the php version of Wechat public platform Wechat web login authorization example analysis" of this article.

截屏2023-12-25 20

The details are as follows:

Wechat public platform to achieve Wechat web page login authorization development is actually very simple, because the official reference program, the following editor looked at a webmaster according to the official reference to do a web page login authorization example, you can take a look.

File 1:index.php

/ / replace it with your own interface information $appid = 'XXXXX';header (' location: https://open.weixin.qq.com/connect/oauth3/authorize?appid='.$appid.'&redirect_uri=127.0.0.1/oauth.php&response_type=code&scope=snsapi_userinfo&state=123&connect_redirect=1#wechat_redirect'); Whether the parameter must indicate that appid is the unique identification of the official account. Redirect_uri is the callback link address redirected after authorization. Use urlencode to process the link. Response_type is the return type. Enter codescope as the application authorization scope, snsapi_base (do not pop up the authorization page, jump directly, and only get the user openid), snsapi_userinfo (pop-up authorization page, you can get nickname, gender and location through openid. And, even if the user is not concerned, as long as the user is authorized to obtain its information) whether the state will be redirected with the state parameter, developers can fill in the parameter value of a-zA-Z0-9 # wechat_redirect must take this parameter whether it is opened directly or redirected to the page

File 2: oauth.php, the code is as follows:

Parameter describes the gender of the openid user's unique identifier, nickname user nickname, sex user. A value of 1 is male, a value of 2 is female, and a value of 0 is the city or country where the personal data of an unknown province user is filled in by the province city ordinary user. For example, China is the profile picture of the CNheadimgurl user. The last value represents the size of the square avatar (there are 0, 46, 64, 96, 132 values optional, 0 means 640 square avatar). This item is empty if the user does not have an avatar. This field is empty if the user does not have an avatar. This field appears only after the user binds the official account to the open platform account of Wechat for (chinaunicom) unionid, such as Wechat Woka user (chinaunicom). For more information, please see: obtaining users' personal Information (UnionID mechanism). These are all the contents of this article entitled "sample Analysis of Wechat Web access Authorization on the php version of Wechat Public platform". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report