PHPackages                             lianyue/weibo-api - 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. lianyue/weibo-api

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

lianyue/weibo-api
=================

Weibo api oauth2 sdk

v0.1.6(10y ago)133Apache2PHPPHP &gt;=5.4.0

Since Mar 25Pushed 10y ago1 watchersCompare

[ Source](https://github.com/lian-yue/weibo-api)[ Packagist](https://packagist.org/packages/lianyue/weibo-api)[ RSS](/packages/lianyue-weibo-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Composer 安装
===========

[](#composer-安装)

```
composer require lianyue/weibo-api

```

微博 OAuth2
=========

[](#微博-oauth2)

### 申请应用

[](#申请应用)

Client Id 就是你的 **Api Key**

Client Secret 就是你的 **App Secret**

### OAuth2 api 列表

[](#oauth2-api-列表)

### Oauth2使用方法

[](#oauth2使用方法)

```
namespace LianYue\WeiboApi;

$oauth2 = new OAuth2(CLIENT_ID, CLIENT_SELECT);
$oauth2->setRedirectUri(CALLBACK_URI);
try {
    // 设置 state
    if (!empty($_COOKIE['weibo_api_state'])) {
        $oauth2->setState($_COOKIE['weibo_api_state']);
    }

    // 取得令牌
    $accessToken = $oauth2->getAccessToken();

    // 访问令牌
    print_r($accessToken);

    // 用户信息
    print_r($oauth2->getUsersShow()->getJson(true));

    // 其他api调用
    print_r($this->api('GET', '/statuses/mentions.json')->response()->getJson(false));
} catch (WeiboApiException $e) {

    // 获取重定向链接
    $uri = $oauth2->getAuthorizeUri();

    // 储存 state
    setcookie('weibo_api_state', $oauth2->getState(), time() + 86400, '/');

    // 重定向
    header('Location: ' . $uri);
}

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

3699d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e8845b75b0b4eb3a40e3e06423ad9ea0014e9c6c723814496e03f17faeaaf00?d=identicon)[LianYue](/maintainers/LianYue)

---

Top Contributors

[![lian-yue](https://avatars.githubusercontent.com/u/6044394?v=4)](https://github.com/lian-yue "lian-yue (4 commits)")

---

Tags

apiclientsdkmapoauthoauth2IPopenconnectweibo

### Embed Badge

![Health badge](/badges/lianyue-weibo-api/health.svg)

```
[![Health](https://phpackages.com/badges/lianyue-weibo-api/health.svg)](https://phpackages.com/packages/lianyue-weibo-api)
```

###  Alternatives

[happyr/linkedin-api-client

LinkedIn API client. Handles OAuth, CSRF protection. Easy to implement and extend. This is a standalone library for any composer project.

1991.6M12](/packages/happyr-linkedin-api-client)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

251.7M1](/packages/mollie-oauth2-mollie-php)[acuityscheduling/acuityscheduling

Acuity Scheduling PHP SDK. Examples and a standard library for Acuity Scheduling integration.

11294.8k](/packages/acuityscheduling-acuityscheduling)[andalisolutions/oauth2-anaf

Anaf OAuth 2.0 support for the PHP League's OAuth 2.0 Client

194.1k](/packages/andalisolutions-oauth2-anaf)

PHPackages © 2026

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