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

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

littlemo/weibo
==============

the littlemo weibo utils

v1.0.1(4y ago)110Apache-2.0PHPPHP ^7.0

Since Nov 15Pushed 4y ago1 watchersCompare

[ Source](https://github.com/littlemolh/composer-weibo)[ Packagist](https://packagist.org/packages/littlemo/weibo)[ Docs](https://ggui.cn/)[ RSS](/packages/littlemo-weibo/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

微博 LittleMo
===========

[](#微博-littlemo)

[![Total Downloads](https://camo.githubusercontent.com/af68cb4c18a19563a8e57166a84ee285a0d82c1a0ee9f8074a6cc3df4e369e3e/68747470733a2f2f706f7365722e707567782e6f72672f6c6974746c656d6f2f776569626f2f646f776e6c6f616473)](https://packagist.org/packages/littlemo/weibo)[![Latest Stable Version](https://camo.githubusercontent.com/f4da62408105f647fcefda423aba8c601814f1f5649e5d25590aaad8fe8636f7/68747470733a2f2f706f7365722e707567782e6f72672f6c6974746c656d6f2f776569626f2f762f737461626c65)](https://packagist.org/packages/littlemo/weibo)[![Latest Unstable Version](https://camo.githubusercontent.com/2dfa2a8ddda9ab8f5d846375de7dc6009dab70562541e1ead7b0cb6f8c61fa7e/68747470733a2f2f706f7365722e707567782e6f72672f6c6974746c656d6f2f776569626f2f762f756e737461626c65)](https://packagist.org/packages/littlemo/weibo)[![PHP Version](https://camo.githubusercontent.com/21223b9ffedc1feec4026ec59947bafeec1e45b69a0e2fd1383975636e8d09a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e302d3838393242462e737667)](http://www.php.net/)[![License](https://camo.githubusercontent.com/16a41f18ad01bcf195b70b67d616720f8be9b278b3ed4a77a202b64cbb5aa38f/68747470733a2f2f706f7365722e707567782e6f72672f6c6974746c656d6f2f776569626f2f6c6963656e7365)](https://packagist.org/packages/littlemo/weibo)

### 介绍

[](#介绍)

php常用工具库

### 安装教程

[](#安装教程)

composer.json

```
{
    "require": {
        "littlemo/weibo": "~1.0.0"
    }
}
```

### 使用说明

[](#使用说明)

#### 获取授权过的Access Token

[](#获取授权过的access-token)

> OAuth2的access\_token接口

##### 示例代码

[](#示例代码)

```
use littlemo\weibo\Oauth2;

$Oauth2 = new Oauth2($client_id, $client_secret);

$result = $Oauth2->access_token($code, $redirect_uri);

if ($result) {
    echo '获取Access token成功';
    $token = $Oauth2->getMessage();
} else {
    echo "获取Access token失败";
    $errorMsg = $Oauth2->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $Class->getIntactMsg();
```

**返回示例**

```
 {
       "access_token": "ACCESS_TOKEN",
       "expires_in": 1234,
       "remind_in":"798114",
       "uid":"12341234"
 }
```

> [官方文档](https://open.weibo.com/wiki/Oauth2/access_token)

#### get\_token\_info

[](#get_token_info)

> 查询用户access\_token的授权相关信息，包括授权时间，过期时间和scope权限。

##### 示例代码

[](#示例代码-1)

```
use littlemo\weibo\Oauth2;

$Oauth2 = new Oauth2();

$result = $Oauth2->get_token_info($access_token);

if ($result) {
    echo '获取token info成功';
    $token = $Oauth2->getMessage();
} else {
    echo "获取token info失败";
    $errorMsg = $Oauth2->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $Class->getIntactMsg();
```

**返回示例**

```
{
      "uid": 1073880650,
      "appkey": 1352222456,
      "scope": null,
      "create_at": 1352267591,
      "expire_in": 157679471
}
```

> [官方文档](https://open.weibo.com/wiki/Oauth2/get_token_info)

#### revokeoauth2

[](#revokeoauth2)

> 授权回收接口，帮助开发者主动取消用户的授权。

##### 示例代码

[](#示例代码-2)

```
use littlemo\weibo\Oauth2;

$Oauth2 = new Oauth2();

$result = $Oauth2->revokeoauth2($access_token);

if ($result) {
    echo '回收成功';
    $token = $Oauth2->getMessage();
} else {
    echo "回收失败";
    $errorMsg = $Oauth2->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $Class->getIntactMsg();
```

**返回示例**

```
{
 	"result":"true"
 }
```

> [官方文档](https://open.weibo.com/wiki/Oauth2/revokeoauth2)

#### show

[](#show)

> 根据用户ID获取用户信息

##### 示例代码

[](#示例代码-3)

```
use littlemo\weibo\User;

$User = new User();

$result = $User->show($access_token, $uid , $screen_name);

if ($result) {
    echo '获取用户信息成功';
    $token = $User->getMessage();
} else {
    echo "获取用户信息失败";
    $errorMsg = $User->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $Class->getIntactMsg();
```

> 参数uid与screen\_name二者必选其一，且只能选其一； 接口升级后，对未授权本应用的uid，将无法获取其个人简介、认证原因、粉丝数、关注数、微博数及最近一条微博内容。

**返回示例**

```
{
    "id": 1404376560,
    "screen_name": "zaku",
    "name": "zaku",
    "province": "11",
    "city": "5",
    "location": "北京 朝阳区",
    "description": "人生五十年，乃如梦如幻；有生斯有死，壮士复何憾。",
    "url": "http://blog.sina.com.cn/zaku",
    "profile_image_url": "http://tp1.sinaimg.cn/1404376560/50/0/1",
    "domain": "zaku",
    "gender": "m",
    "followers_count": 1204,
    "friends_count": 447,
    "statuses_count": 2908,
    "favourites_count": 0,
    "created_at": "Fri Aug 28 00:00:00 +0800 2009",
    "following": false,
    "allow_all_act_msg": false,
    "geo_enabled": true,
    "verified": false,
    "status": {
        "created_at": "Tue May 24 18:04:53 +0800 2011",
        "id": 11142488790,
        "text": "我的相机到了。",
        "source": "新浪微博",
        "favorited": false,
        "truncated": false,
        "in_reply_to_status_id": "",
        "in_reply_to_user_id": "",
        "in_reply_to_screen_name": "",
        "geo": null,
        "mid": "5610221544300749636",
        "annotations": [],
        "reposts_count": 5,
        "comments_count": 8
    },
    "allow_all_comment": true,
    "avatar_large": "http://tp1.sinaimg.cn/1404376560/180/0/1",
    "verified_reason": "",
    "follow_me": false,
    "online_status": 0,
    "bi_followers_count": 215
}
```

> [官方文档](https://open.weibo.com/wiki/2/users/show)

#### domain\_show

[](#domain_show)

> 通过个性化域名获取用户资料以及用户最新的一条微博

##### 示例代码

[](#示例代码-4)

```
use littlemo\weibo\User;

$User = new User();

$result = $User->domain_show($access_token, $domain);

if ($result) {
    echo '获取用户资料成功';
    $token = $User->getMessage();
} else {
    echo "获取用户资料失败";
    $errorMsg = $User->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $Class->getIntactMsg();
```

> 接口升级后，对未授权本应用的uid，将无法获取其个人简介、认证原因、粉丝数、关注数、微博数及最近一条微博内容。

**返回示例**

```
{
    "id": 1404376560,
    "screen_name": "zaku",
    "name": "zaku",
    "province": "11",
    "city": "5",
    "location": "北京 朝阳区",
    "description": "人生五十年，乃如梦如幻；有生斯有死，壮士复何憾。",
    "url": "http://blog.sina.com.cn/zaku",
    "profile_image_url": "http://tp1.sinaimg.cn/1404376560/50/0/1",
    "domain": "zaku",
    "gender": "m",
    "followers_count": 1204,
    "friends_count": 447,
    "statuses_count": 2908,
    "favourites_count": 0,
    "created_at": "Fri Aug 28 00:00:00 +0800 2009",
    "following": false,
    "allow_all_act_msg": false,
    "geo_enabled": true,
    "verified": false,
    "status": {
        "created_at": "Tue May 24 18:04:53 +0800 2011",
        "id": 11142488790,
        "text": "我的相机到了。",
        "source": "新浪微博",
        "favorited": false,
        "truncated": false,
        "in_reply_to_status_id": "",
        "in_reply_to_user_id": "",
        "in_reply_to_screen_name": "",
        "geo": null,
        "mid": "5610221544300749636",
        "annotations": [],
        "reposts_count": 5,
        "comments_count": 8
    },
    "allow_all_comment": true,
    "avatar_large": "http://tp1.sinaimg.cn/1404376560/180/0/1",
    "verified_reason": "",
    "follow_me": false,
    "online_status": 0,
    "bi_followers_count": 215
}
```

> [官方文档](https://open.weibo.com/wiki/2/users/domain_show)

#### jsapi\_ticket

[](#jsapi_ticket)

> jsapi\_ticket 是网页用于调用微博客户端内JS接口的临时票据

##### 示例代码

[](#示例代码-5)

```
use littlemo\weibo\JsApi;

$JsApi = new JsApi($client_id, $client_secret);

$result = $JsApi->ticket($access_token, $domain);

if ($result) {
    echo '获取 ticket 成功';
    $token = $JsApi->getMessage();
} else {
    echo "获取 ticket 失败";
    $errorMsg = $JsApi->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $Class->getIntactMsg();
```

> 其中，js\_ticket 为需要获取的 jsapi\_ticket ，expire\_time 为过期时间。

**返回示例**

```
{
    "result": true,
    "appkey": "",
    "js_ticket": "",
    "expire_time": 7199
}
```

> [官方文档](https://open.weibo.com/wiki/Weibo-JS_V2)

#### 签名算法

[](#签名算法)

> jsapi\_ticket 是网页用于调用微博客户端内JS接口的临时票据

##### 示例代码

[](#示例代码-6)

```
use littlemo\weibo\JsApi;

$JsApi = new JsApi($client_id);

$result = $JsApi->signature($jsapi_ticket, $noncestr,  $timestamp, $url, $client_id);
```

参数

参数类型是否必填说明jsapi\_ticketstringY网页用于调用微博客户端内JS接口的临时票据noncestrstringN随机字符串timestampstringN时间戳urlstringN当前网页的URL，不包含#及其后面部分client\_idstringY申请应用时分配的AppKey。> 其中，js\_ticket 为需要获取的 jsapi\_ticket ，expire\_time 为过期时间。

**返回示例**

```
Wm3WZYTPz0wzccnW

```

示例

```
[
    'appkey' => $client_id,
    'timestamp' => $timestamp,
    'noncestr' => $noncestr,
    'signature' => $result,
    'url' => $url,
];
```

> [官方文档](https://open.weibo.com/wiki/Weibo-JS_V2)

### 参与贡献

[](#参与贡献)

1. littlemo

### 特技

[](#特技)

- 统一、精简

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~14 days

Total

2

Last Release

1628d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1931459c472417fca4c82cff5c9e0a34c0501d8c95409c5de34f4f9efe4ceab?d=identicon)[25362583](/maintainers/25362583)

![](https://www.gravatar.com/avatar/0172f1321449429155012129cc51c21fe647f690c0a9bd992496482394fe014a?d=identicon)[xiaowei95](/maintainers/xiaowei95)

---

Top Contributors

[![littlemolh](https://avatars.githubusercontent.com/u/26665792?v=4)](https://github.com/littlemolh "littlemolh (3 commits)")[![25362583](https://avatars.githubusercontent.com/u/16798708?v=4)](https://github.com/25362583 "25362583 (1 commits)")

---

Tags

toolutilsweibolittlemo

### Embed Badge

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

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

###  Alternatives

[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[phing/phing

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.

1.2k21.7M876](/packages/phing-phing)[bamarni/composer-bin-plugin

No conflicts for your bin dependencies

52722.0M859](/packages/bamarni-composer-bin-plugin)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4875.5M16](/packages/voku-arrayy)[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M16](/packages/vaimo-composer-patches)[voku/stringy

A string manipulation library with multibyte support

1783.8M19](/packages/voku-stringy)

PHPackages © 2026

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