Home PHP Libraries Other libraries php qq login class
php qq login class
<?php
class qqlogin{
  public $app_id;
  public $app_key;
  public $callback;
  public $code;
  public $state;
  public function __construct($app_id,$app_key,$callback){
    $this->code = isset($_REQUEST['code'])? $_REQUEST['code'] : '';
    $this->state = isset($_REQUEST['state'])? $_REQUEST['state'] : '';
    $this->app_id = $app_id;
    $this->app_key = $app_key;
    $this->callback = $callback;
  }
  public function get_token(){
    $url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=".$this->app_id."&client_secret=".$this->app_key."&code=".$this->code."&redirect_uri=".urlencode($this->callback);
    $str = $this->visit_url($url);
    parse_str($str,$arr);
    return $arr;
  }

This is a QQ login class, used for the QQ login interface,

php-qq login class, the class has been encapsulated, used for the QQ login callback page. app_id, app_key, callback

You need to go to the QQ Internet documentation to understand the QQ access process. This type only encapsulates the callback function.

Request the URL address, get the return string, convert the string into a format that can be json_decoded, and get the page return value through curl.



Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

javascript - thinkphp qq login javascript - thinkphp qq login

06 Jul 2016

The entry file of phpSDK is qqConnectAPI.php, which means that this file must be imported before using its class. Of course, this file can be imported in thinkphp. However, if you want to instantiate the QC class after the introduction, it will not work, and it will prompt that the class cannot be found. The code of the qqConnectAPI.php file is as follows: req...

What are some very useful class libraries or tool libraries for PHP? What are some very useful class libraries or tool libraries for PHP?

06 Jul 2016

What are some very useful class libraries or tool libraries for PHP?

How Do I Link Static Libraries That Depend on Other Static Libraries? How Do I Link Static Libraries That Depend on Other Static Libraries?

13 Dec 2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

How to do single-user app login in PHP How to do single-user app login in PHP

06 Jul 2016

The current requirement is for apps to be similar to QQ and other communication tools. Single user login. Logins from other places are blocked. Previous logins. I don’t know how to implement it. Has anyone done this?

Ask a question about QQ Internet login: Unify users between multiple applications under one developer account Ask a question about QQ Internet login: Unify users between multiple applications under one developer account

06 Jul 2016

I used the WeChat official account to log in, and then I learned that the WeChat open platform has a unionid. As long as the developer binds his or her official account or other applications, the unionid under the current developer account will be the same for the same WeChat user. , which is helpful when developers have multiple applications...

Why Do PHP Developers Use Leading Underscores in Class Methods? Why Do PHP Developers Use Leading Underscores in Class Methods?

11 Nov 2024

Hidden Truths: The Leading Underscore in PHP Class MethodsWhen browsing PHP libraries, one might stumble upon class methods prefixed with a...

See all articles