WeChat open platform development-Introduction to website application WeChat login

Source: Internet
Author: User
In this public platform development tutorial, we will introduce how to use open platform interfaces to implement the QR code logon function. In this public platform development tutorial, we will introduce how to use open platform interfaces to implement the QR code logon function.

Preparations

Website application logon is an OAuth2.0 authorized logon system based on OAuth2.0 protocol standards.

Before OAuth2. performs authorized OAuth2.0 login and access, register a developer account on the open platform, have a verified website application, and obtain the corresponding AppID and AppSecret, after applying for logon and passing the review, you can start the access process.

        《script》            var obj = new WxLogin({              id: "login_container",              appid: "wxed782be999f86e0e",              scope: "snsapi_login",              redirect_uri: encodeURIComponent("http://" + window.location.host + "/login.php"),              state: Math.ceil(Math.random()*1000),              style: "black",              href: ""});        《script》

Parameter description

Parameters Required? Description
Id Yes Container id of the QR code displayed on the third-party page
Appid Yes Unique Application ID, obtained after the application is submitted to the open platform for application review
Scope Yes Application authorization scope. multiple scopes are separated by commas (,). Currently, only snsapi_login can be entered for web applications.
Redirect_uri Yes Redirection address, which requires UrlEncode
State No It is used to maintain the request and callback status, and the authorization request is taken back to a third party as is. This parameter can be used to prevent csrf attacks (Cross-Site Request Forgery attacks). it is recommended that a third party carry this parameter and set it to a simple random number and a session for verification.
Style No "Black" and "white" are available. the default value is black text description. See the FAQ at the bottom of the document.
Href No Custom style links. third parties can overwrite the default style as needed. See the FAQ at the bottom of the document.

The complete code is as follows:

            
                         

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.