PHPackages                             xiabin/oauth2-sinaweibo - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. xiabin/oauth2-sinaweibo

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

xiabin/oauth2-sinaweibo
=======================

Sina Weibo OAuth 2.0 Client Provider for The PHP League OAuth2-Client

v1.0.1(9y ago)167MITPHPPHP &gt;=5.5.0

Since Jun 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/xiabin/oauth2-sinaweibo)[ Packagist](https://packagist.org/packages/xiabin/oauth2-sinaweibo)[ RSS](/packages/xiabin-oauth2-sinaweibo/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

SinaWeibo Provider for OAuth 2.0 Client
=======================================

[](#sinaweibo-provider-for-oauth-20-client)

[![license](https://camo.githubusercontent.com/01b3ab8901555dd04c48460896ecf18cbeafcdaa2d4b3c74aed1f80e3e72369d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f78696162696e2f6f61757468322d73696e61776569626f2e7376673f6d61784167653d32353932303030)](https://github.com/xiabin/oauth2-sinaweibo/blob/master/LICENSE.md)[![Packagist](https://camo.githubusercontent.com/52ad3b3a65739c64f1847688f6b550d4d8e79ff50a00569696782dfd6917b32c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f78696162696e2f6f61757468322d73696e61776569626f2e7376673f6d61784167653d323539323030303f7374796c653d706c6173746963)](https://packagist.org/packages/xiabin/oauth2-sinaweibo)[![Build Status](https://camo.githubusercontent.com/24a0e9aba62244a69b149c2bb7b3e3b83b4152a4f071953f582011646d897fab/68747470733a2f2f7472617669732d63692e6f72672f78696162696e2f6f61757468322d73696e61776569626f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/xiabin/oauth2-sinaweibo)[![Coverage Status](https://camo.githubusercontent.com/849ff14036c39836f3dac8ae79bf98e7d4ddf05c46cc02f508e3841b3f7661ef/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f78696162696e2f6f61757468322d73696e61776569626f2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xiabin/oauth2-sinaweibo/code-structure)[![Quality Score](https://camo.githubusercontent.com/42625bf4b010bb782f819fb94a286137dd1890412487cc2435bb908cc949b4af/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7468657068706c65616775652f6f61757468322d6769746875622f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xiabin/oauth2-sinaweibo/)[![Packagist](https://camo.githubusercontent.com/a0930be886e63a78a3f3623367b38f607f045a06c7995a5d61e742a2b94e3941/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f78696162696e2f6f61757468322d73696e61776569626f2e7376673f6d61784167653d32353932303030)](https://packagist.org/packages/xiabin/oauth2-sinaweibo)

这个组件基于 PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

安装
--

[](#安装)

用composer安装:

```
composer require xiabin/oauth2-sinaweibo

```

用例
--

[](#用例)

### 获取token

[](#获取token)

```
$provider = new Xiabin\OAuth2\Client\Provider\SinaWeibo([
    'clientId'          => '{sinaweibo-client-id}',
    'clientSecret'      => '{sinaweibo-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
]);

if (!isset($_GET['code'])) {

    //如果没有code就去获取
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

  //判断state与之前使用的是否一致
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    //获取accesstoken
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    ...
}
```

测试
--

[](#测试)

```
$ ./vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/xiabin/oauth2-sinaweibo/blob/master/LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity60

Established project with proven stability

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 ~5 days

Total

3

Last Release

3649d ago

Major Versions

v0.1.0 → v1.0.02016-06-25

### Community

Maintainers

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

---

Tags

clientoauthoauth2authorizationauthorisationsina weibo

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/xiabin-oauth2-sinaweibo/health.svg)

```
[![Health](https://phpackages.com/badges/xiabin-oauth2-sinaweibo/health.svg)](https://phpackages.com/packages/xiabin-oauth2-sinaweibo)
```

###  Alternatives

[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2276.2M36](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1152.7M11](/packages/patrickbussmann-oauth2-apple)[omines/oauth2-gitlab

GitLab OAuth 2.0 Client Provider for The PHP League OAuth2-Client

36761.9k15](/packages/omines-oauth2-gitlab)[league/oauth2-instagram

Instagram OAuth 2.0 Client Provider for The PHP League OAuth2-Client

661.1M43](/packages/league-oauth2-instagram)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

261.8M1](/packages/mollie-oauth2-mollie-php)[dalpras/oauth2-gotowebinar

LogMeIn GoToWebinar OAuth 2.0 Client Provider for the PHP League's OAuth 2.0 Client

1245.5k](/packages/dalpras-oauth2-gotowebinar)

PHPackages © 2026

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