PHPackages                             itwmw/go-cq-http-sdk - 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. itwmw/go-cq-http-sdk

ActiveLibrary

itwmw/go-cq-http-sdk
====================

go-cqhttp的SDK

v0.6.1(2y ago)11841Apache-2.0PHPPHP &gt;=8.0

Since Jun 1Pushed 2y agoCompare

[ Source](https://github.com/MicroDreamTeam/go-cq-http-sdk)[ Packagist](https://packagist.org/packages/itwmw/go-cq-http-sdk)[ RSS](/packages/itwmw-go-cq-http-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (16)Used By (0)

 [ ![go-cqhttp](winres/icon.png) ](https://ishkong.github.io/go-cqhttp-docs/)

go-cqhttp-sdk
-------------

[](#go-cqhttp-sdk)

**[go-cqhttp](https://github.com/Mrs4s/go-cqhttp)项目的PHP版SDK，拥有完整注释和代码提示**

 [ ![license](https://camo.githubusercontent.com/bbe2445acffbb6dc1fe1fcb98e1e601cc4872f442f23b164b56189aeb8cd8dd0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d6963726f447265616d5465616d2f676f2d63712d687474702d73646b) ](https://raw.githubusercontent.com/MicroDreamTeam/go-cq-http-sdk/master/LICENSE) [ ![release](https://camo.githubusercontent.com/2addeba46270a294c6caad704bb241b65374225883ca76467fa563b0f83104e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974776d772f676f2d63712d687474702d73646b) ](https://packagist.org/packages/itwmw/go-cq-http-sdk) [![php-version](https://camo.githubusercontent.com/6406384a0e0a059ef19aadfd6eaceb1ca92ae41f22a42c584f4b40b35e5ff477/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6974776d772f676f2d63712d687474702d73646b2f706870)](https://camo.githubusercontent.com/6406384a0e0a059ef19aadfd6eaceb1ca92ae41f22a42c584f4b40b35e5ff477/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6974776d772f676f2d63712d687474702d73646b2f706870)

 [文档](https://docs.go-cqhttp.org/) · [下载](https://github.com/Mrs4s/go-cqhttp/releases) · [开始使用](https://docs.go-cqhttp.org/guide/quick_start.html)

### 安装

[](#安装)

```
composer require itwmw/go-cq-http-sdk
```

### 使用示例

[](#使用示例)

```
$api = new Itwmw\GoCqHttp\Api();
// 发送私聊消息
$api->message->sendMsg('测试消息', 'private', 995645888);
```

### 处理上报消息

[](#处理上报消息)

SDK内置消息的处理：

```
$server = $api->getServer();
```

你可以通过中间件模式来处理消息：

```
use Itwmw\GoCqHttp\Data\Post\BasePostMessage;

$server->addHandler(function(BasePostMessage $message, \Closure $next) {
    // 处理消息
    return $next($message);
})->addHandler(function(BasePostMessage $message, \Closure $next) {
    // 处理消息
    return $next($message);
})->addHandler(function(BasePostMessage $message, \Closure $next) {
    // 处理消息
    return $next($message);
})->addHandler(function(BasePostMessage $message, \Closure $next) {
    // 处理消息
    return $next($message);
});

echo $server->handle();
```

#### 使用独立的类来处理消息

[](#使用独立的类来处理消息)

```
use Itwmw\GoCqHttp\Data\Post\BasePostMessage;

class MessageHandle
{
    public function __invoke(BasePostMessage $message, \Closure $next)
    {
        // 处理消息
        return $next($message);
    }
}

$server->addHandler(MessageHandle::class);
```

> 也支持`callable`类型的处理器

#### 注册指定类型的处理器

[](#注册指定类型的处理器)

```
use Itwmw\GoCqHttp\Data\Struct\Enum\PostMessageType;
use Itwmw\GoCqHttp\Data\Post\Message\PrivateMessage;

$server->addMessageListener(PostMessageType::PRIVATE, function (PrivateMessage $message, \Closure $next) {
    // 处理消息
    return $next($message);
});
```

```
use Itwmw\GoCqHttp\Data\Struct\Enum\PostNoticeType;
use Itwmw\GoCqHttp\Data\Post\Notice\GroupIncreaseNotice;

$server->addNoticeListener(PostNoticeType::GROUP_INCREASE, function (GroupIncreaseNotice $message, Closure $next) {
    // 处理群成员增加
    return $next($message);
});
```

> 同样也支持使用独立的类来处理消息

#### 快捷操作

[](#快捷操作)

部分类型的消息支持快捷操作，快捷操作的方法为 `response`，例：

```
use Itwmw\GoCqHttp\Data\Post\Message\PrivateMessage;

$server->addMessageListener(PostMessageType::PRIVATE, function (PrivateMessage $message, \Closure $next) {
    if ('再见' === $message->message) {
        return $message->response('bye~');
    }
    return $next($message);
});
```

### 支持

[](#支持)

Bot账号相关的Api```
$api->bot;
```

API功能getLoginInfo获取登录号信息setQqProfile设置登录号资料qiDianGetAccountInfo获取企点账号信息getModelShow获取在线机型setModelShow设置在线机型getOnlineClients获取当前账号在线客户端列表好友相关的Api```
$api->friend;
```

API功能getStrangerInfo获取陌生人信息GetFriendList获取好友列表getUnidirectionalFriendList获取单向好友列表deleteFriend删除好友deleteUnidirectionalFriend删除单向好友getOnlineClients获取当前账号在线客户端列表消息相关的Api```
$api->message;
```

API功能sendPrivateMsg发送私聊消息sendGroupMsg发送群聊消息sendMsg发送消息getMsg获取消息deleteMsg撤回消息markMsgAsRead标记消息已读getForwardMsg获取合并转发内容sendGroupForwardMsg发送合并转发 ( 群聊 )sendPrivateForwardMsg发送合并转发 ( 好友 )getGroupMsgHistory获取群消息历史记录图片相关的Api```
$api->image;
```

API功能getImage获取图片信息canSendImage检查是否可以发送图片ocrImage图片 OCR语音相关的Api```
$api->record;
```

API功能getRecord获取语音canSendRecord检查是否可以发送语音处理请求相关的Api```
$api->request;
```

API功能setFriendAddRequest处理加好友请求setGroupAddRequest处理加群请求／邀请群信息相关的Api```
$api->groupInfo;
```

API功能getGroupInfo获取群信息getGroupList获取群列表getGroupMemberInfo获取群成员信息getGroupMemberList获取群成员列表getGroupHonorInfo获取群荣誉信息getGroupSystemMsg获取群系统消息getEssenceMsgList获取精华消息列表getGroupAtAllRemain获取群 @全体成员 剩余次数群设置相关的Api```
$api->groupSetting;
```

API功能setGroupName设置群名setGroupPortrait设置群头像setGroupAdmin设置群管理员setGroupCard设置群名片 ( 群备注 )setGroupSpecialTitle设置群组专属头衔群操作相关的Api```
$api->groupAction;
```

API功能setGroupBan群单人禁言setGroupWholeBan群全员禁言setGroupAnonymousBan群匿名用户禁言setEssenceMsg设置精华消息deleteEssenceMsg移出精华消息sendGroupSign群打卡setGroupAnonymous群设置匿名sendGroupNotice发送群公告getGroupNotice获取群公告setGroupKick群组踢人setGroupLeave退出群组群文件相关的Api```
$api->groupFile;
```

API功能uploadGroupFile上传群文件deleteGroupFile删除群文件createGroupFileFolder创建群文件文件夹deleteGroupFolder删除群文件文件夹getGroupFileSystemInfo获取群文件系统信息getGroupRootFiles获取群根目录文件列表getGroupFilesByFolder获取群子目录文件列表getGroupFileUrl获取群文件资源链接uploadPrivateFile上传私聊文件Go-CqHttp相关的Api```
$api->cq;
```

API功能getCookies获取 CookiesgetCsrfToken获取 CSRF TokengetCredentials获取 QQ 相关接口凭证getVersionInfo获取版本信息getStatus获取状态cleanCache清理缓存reloadEventFilter重载事件过滤器downloadFile下载文件到缓存目录checkUrlSafely检查链接安全性getWordSlices获取中文分词 ( 隐藏 API )handleQuickOperation对事件执行快速操作 ( 隐藏 API )CQ 码支持对应的类功能`Itwmw\GoCqHttp\CqCode\Face`QQ 表情`Itwmw\GoCqHttp\CqCode\Record`语音`Itwmw\GoCqHttp\CqCode\Video`短视频`Itwmw\GoCqHttp\CqCode\At`@某人`Itwmw\GoCqHttp\CqCode\Share`链接分享`Itwmw\GoCqHttp\CqCode\Music`音乐分享`Itwmw\GoCqHttp\CqCode\MusicCustom`自定义音乐分享`Itwmw\GoCqHttp\CqCode\Image`图片`Itwmw\GoCqHttp\CqCode\Reply`回复`Itwmw\GoCqHttp\CqCode\RedBag`红包`Itwmw\GoCqHttp\CqCode\Poke`戳一戳`Itwmw\GoCqHttp\CqCode\Gift`礼物`Itwmw\GoCqHttp\CqCode\Forward`合并转发`Itwmw\GoCqHttp\CqCode\Xml`XML 消息`Itwmw\GoCqHttp\CqCode\Json`JSON 消息`Itwmw\GoCqHttp\CqCode\CardImage`装逼大图`Itwmw\GoCqHttp\CqCode\Tts`文本转语音#### 使用示例

[](#使用示例-1)

发送：

```
use Itwmw\GoCqHttp\Api;
use Itwmw\GoCqHttp\CqCode\Tts;

$api = new Api();
$tts = new Tts('你好');
$api->message->sendMsg($tts, user_id: 995645888);
```

解析接受到的消息：

```
$msg = "[CQ:share,url=https://www.baidu.com/,title=百度一下,content=百度一下，你就知道,image=https://www.baidu.com/img/bd_logo1.png]";
$share = Share::create($msg);
print_r($share);
//Itwmw\GoCqHttp\CqCode\Share Object
//(
//    [url] => https://www.baidu.com/
//    [title] => 百度一下
//    [content] => 百度一下，你就知道
//    [image] => https://www.baidu.com/img/bd_logo1.png
//)
echo $share;
// [CQ:share,url=https://www.baidu.com/,title=百度一下,content=百度一下，你就知道,image=https://www.baidu.com/img/bd_logo1.png]
```

### 关于：

[](#关于)

QQ群： 852297017

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.2% 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 ~2 days

Total

15

Last Release

1037d ago

PHP version history (2 changes)v0.0.1PHP &gt;=8.1

v0.3.1PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d8c7cd0a79ae4a225651cbd75d83faa585f8e8d909322db9b52fd176949562f?d=identicon)[itwmw](/maintainers/itwmw)

---

Top Contributors

[![YepYuYu](https://avatars.githubusercontent.com/u/84311710?v=4)](https://github.com/YepYuYu "YepYuYu (33 commits)")[![moniang](https://avatars.githubusercontent.com/u/61287199?v=4)](https://github.com/moniang "moniang (4 commits)")

### Embed Badge

![Health badge](/badges/itwmw-go-cq-http-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/itwmw-go-cq-http-sdk/health.svg)](https://phpackages.com/packages/itwmw-go-cq-http-sdk)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k20](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)

PHPackages © 2026

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