PHPackages                             hafly/qqconnect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hafly/qqconnect

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hafly/qqconnect
===============

QQ互联SDK 2.1版本

v2.1.1(2y ago)012MITPHP

Since Apr 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/hafly/qqconnect)[ Packagist](https://packagist.org/packages/hafly/qqconnect)[ RSS](/packages/hafly-qqconnect/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (5)Used By (0)

QQConnect
=========

[](#qqconnect)

只是为了方便自己写网站使用，官方的sdk包用起来很是不方便，每次使用都要翻看文档和示例。

也看过别人封装的代码，要么就只适用于TP5 要么就是不做修改的直接搬运官方sdk，使用方法Demo 也是没有，让我感觉用起来太麻烦了。

QQ互联，基于官方sdk包修改与封装，另许多框架都对session操作进行了重新封装，避免在框架中使用时无法读取$\_SESSION数据，这里将不做任何的数据存储，access\_token 的有效期维护，需要自行处理。

### 说明

[](#说明)

官方文档

1. access\_token 过期时间为30天。如果存储的access token过期，请重新走登录流程，access token 的数据缓存需自行维护。
2. 代码中使用了 $\_GET 全局变量获取数据。
3. 代码不适用于 swoole 类型的常驻内存框架使用。
4. 如需避免抛出的异常信息暴露给用户，建议使用 try{ }catch(){} 捕获。

### 业务流程

[](#业务流程)

1. 实例化 QC类 执行 qq\_login() 方法， 会生成一个QQ的登陆URL，访问该URL，进行授权登陆。
2. 授权登陆成功，会携带 code 跳转至设置的回调地址， 使用 qq\_callback() 接收 code值，（code值是获取access\_token的凭证），从而获取 access\_token
3. 凭借 access\_token 获取 用户的 open\_id
4. 有了 access\_token 与 open\_id 执行 setKeysArr() 方法，设置接口的公共请求参数。
5. 执行 get\_user\_info() 方法获取用户信息，写入数据表

### 代码示例

[](#代码示例)

```
    $appid = "102***947"  //应用appid
    $appkey = "FuMaaMwJT***ew0pP" //应用appkey
    $callback  = "https://www.***.cn/login/qcallback" //应用授权回调地址
    $scope = "get_user_info,add_share"  //申请获取的应用权限，多个以英文逗号相隔

```

```
use Hafly\QQConnect\QC;

    // qq登录
    public function qq()
    {
        $qc = new QC($appid,$appkey,$callback,$scope);
       return redirect($qc->qq_login());
    }

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

812d ago

Major Versions

v1.0.1 → v2.1.02024-04-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13634263?v=4)[hafly](/maintainers/hafly)[@hafly](https://github.com/hafly)

---

Top Contributors

[![hafly](https://avatars.githubusercontent.com/u/13634263?v=4)](https://github.com/hafly "hafly (4 commits)")

### Embed Badge

![Health badge](/badges/hafly-qqconnect/health.svg)

```
[![Health](https://phpackages.com/badges/hafly-qqconnect/health.svg)](https://phpackages.com/packages/hafly-qqconnect)
```

###  Alternatives

[ip2location/ip2location-laravel

Lookup for visitor's IP information, such as country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type.

82548.8k1](/packages/ip2location-ip2location-laravel)[michalmanko/php-library-holiday

A library to calculate holidays

2182.4k1](/packages/michalmanko-php-library-holiday)[typo3/cms-introduction

The Official TYPO3 Introduction Package

1882.7k6](/packages/typo3-cms-introduction)[alt-design/alt-sitemap

Alt Sitemap addon, create a sitemap from Statamic entries

1223.5k](/packages/alt-design-alt-sitemap)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
