Php qq login development tutorial, phpqq login tutorial

Source: Internet
Author: User

Php qq login development tutorial, phpqq login tutorial

Third-party logon is to use third-party software such as QQ, Weibo, and others that are familiar to you to log on to your website. This eliminates the need to register accounts and quickly retain users, the registration process is relatively complex. Next I will explain how to use PHP to develop the QQ login function.

1, enter QQ Internet official website login (you can use your own QQ or re-register a QQ number as our project separate QQ management), address: https://connect.qq.com/

2. Click "Application Management" to go To the QQ Internet management center, where you can create related applications.Website applicationAndMobile applications.Select the desired application to fill in the information (the review takes about 7 days). After the application is approved, you will get the app id.

And APP Key, Please take a note! Please take a note! Please take a note!(Three important things !!!)

  3. Get the related interface: get_user_info.

4, download QQ associated demo http://wiki.connect.qq.com/sdk%E4%B8%8B%E8%BD%BD I download is PHP SDK v2.1

 

5. Carefully observe the sdk and we will find that it contains four folders and two files, the most important of which is the API folder, I think the rest can be ignored (You can also read it). Follow this document step by step to implement the login function.

6. Copy the API folder to your project. As for which folder to copy to the project, you only need to introduce the folder and check your mood. Make preparations in the early stage, the next step is to write the code.

--------------------------------------------------- Gorgeous but cool split line ---------------------------------------------------------

 

7. Open the API folder you copied to the project. There is a comm folder. open comm again and you will see a guy named inc. php. Open it! Fill in the APPID and APPKEY recorded in your small book to the relevant location. The approximate form is as follows:  

<? Php die ('forbidden ');?>
{"Appid": "Your appid", "appkey": "Your appkey", "callback": "Your Website callback domain", "scope ": "get_user_info "}

8. The Code is as follows:

  

<? Php/*** Created by PhpStorm. * User: qichao * Date: 2018/1/31 * Time: */namespace wechat \ controllers; use wechat \ common \ BaseController; require (_ DIR __. '/.. /tools/API/qqConnectAPI. php '); // introduce the QQ Internet SDK, which is introduced according to the path of my own project. Class QqloginController extends BaseController {// logon method public function actionQqlogin () {$ qc = new \ QC (); $ qc-> qq_login ();} // This method is the address that you want to jump back to after successful logon through QQ. For example, if you want to jump to Baidu after successful logon, you can change the $ url below to the Baidu link! Public function actionCallback () {header ("Content-type: text/html; charset = UTF-8 ");/*
Please develop the relevant code based on your project development needs (such as getting the nickname, profile picture, and age of the logged-on user). The specific data acquisition method is as follows, please refer to QQ interconnection documentation $ qc = new \ QC (); $ access_token = $ qc-> qq_callback (); $ openid = $ qc-> get_openid (); */$ url = "http://wechat.xxx.cn/index.php? R = cms/home "; header (" Location: ". $ url); exit ();}}

At this point, your entire process is finished. It's easy !!! The entire functional process is similar:

If you encounter the following problems during development:

File_get_contents (): Unable to find the wrapper & quot; https & quot;-did you forget to enable it when you configured PHP?

 

The reason for this error is very simple. The encryption module in the php configuration is not enabled.

 

Solution: 1. In the (windows) php. ini configuration file, locate the location shown in blue and remove the semicolon before extension = php_openssl.dll.

After removing it, restart the Apache or nginx server and access it again.

2. For PHP in linux, you must install the openssl module. After installation, you can access it.

 

 

If you still encounter problems during development, please leave a message or add me QQ: 1193553883

This article is original. Please leave a message

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.