PHPackages                             qingclouds/work-wechat-developer - 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. qingclouds/work-wechat-developer

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

qingclouds/work-wechat-developer
================================

企业微信php-sdk

v1.0.0(3y ago)026↓100%MITPHPPHP &gt;=7.0

Since Jun 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Fucntion/work-wechat-developer)[ Packagist](https://packagist.org/packages/qingclouds/work-wechat-developer)[ RSS](/packages/qingclouds-work-wechat-developer/feed)WikiDiscussions master Synced 1mo ago

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

work-wechat
===========

[](#work-wechat)

环境需求
----

[](#环境需求)

- PHP &gt;= 7.0.0
- [Composer](https://getcomposer.org/) &gt;= 2.0

安装
--

[](#安装)

```
composer require qingclouds/work-wechat-developer
```

#### [验证URL有效性](https://developer.work.weixin.qq.com/document/path/90238#%E9%AA%8C%E8%AF%81url%E6%9C%89%E6%95%88%E6%80%A7)

[](#验证url有效性)

```
$service = new WorkWechat\EventService('corpId','encodingAesKey','token');
try{
    // 需要自行urldecode
    echo $service->verifyURL('msgSignature',(int)'timestamp','nonce','msgEncrypt');
}catch (\Exception $e){
    print $e;
    echo '';
}
```

#### [接收post业务数据](https://developer.work.weixin.qq.com/document/path/91116#32-%E6%94%AF%E6%8C%81http-post%E8%AF%B7%E6%B1%82%E6%8E%A5%E6%94%B6%E4%B8%9A%E5%8A%A1%E6%95%B0%E6%8D%AE)

[](#接收post业务数据)

```
$service = new WorkWechat\EventService('corpId','encodingAesKey','token');
$xml = file_get_contents("php://input");
try{
    // 需要自行urldecode
    // 接收到的数据已转为array
    $service->decryptMsg('msgSignature',(int)'timestamp','nonce',$xml);
}catch (\Exception $e){
    print $e;
    echo 'fail';
}
```

#### [网页授权](https://developer.work.weixin.qq.com/document/path/91022)

[](#网页授权)

```
$url = WorkWechat\AuthService::getRedirectUrl('corpId','https://www.baidu.com')
```

#### [扫码登录](https://developer.work.weixin.qq.com/document/path/91019)

[](#扫码登录)

```
$url = WorkWechat\AuthService::getQrCodeUrl('corpId','agentId','https://www.baidu.com','')
```

#### [获取access\_token](https://developer.work.weixin.qq.com/document/path/91039)

[](#获取access_token)

```
// 已增加本地文件缓存
$service = new WorkWechat\AccessTokenService('corpId','secret');
$accessToken = $service->getToken();
// 刷新access_token
$accessToken = $service->refresh();
```

#### [获取访问用户身份](https://developer.work.weixin.qq.com/document/path/91023)

[](#获取访问用户身份)

```
$service = new WorkWechat\UserService();
$service->setAccessToken($accessToken);
$service->companyUserByCode('code');
```

#### [读取成员](https://developer.work.weixin.qq.com/document/path/90196)

[](#读取成员)

```
$userService = new WorkWechat\UserService();
$userService->setAccessToken($accessToken);
$userService->detail('userId')
```

#### [获取客户详情](https://developer.work.weixin.qq.com/document/path/92114)

[](#获取客户详情)

```
$customerService = new WorkWechat\CustomerService();
$customerService->setAccessToken($accessToken);
$customerService->customerDetail('externalUserid')
```

#### [联系客户统计](https://developer.work.weixin.qq.com/document/path/92132)

[](#联系客户统计)

```
$customerService = new WorkWechat\CustomerService();
$customerService->setAccessToken($accessToken);
$customerService->userBehaviorData(['userid','userid',...],['deptmentId',...],1618780712,1649903913)
```

#### 企业部门

[](#企业部门)

```
$departmentService = new WorkWechat\DepartmentService();
$departmentService->setAccessToken($accessToken);
// 获取所有部门
$departmentService->list();
// 获取某个部门及下级部门
$departmentService->list(id);
// 部门详情
$departmentService->detail(id);

// 所有部门及部门下属员工
$departmentService->totalUserList();

// 所有部门及部门下属员工 树形结构
$departmentService->departmentTreeANdTotalUser();
```

#### [发送文本消息](https://developer.work.weixin.qq.com/document/path/90236#%E6%96%87%E6%9C%AC%E6%B6%88%E6%81%AF)

[](#发送文本消息)

```
$messageService = new WorkWechat\MessageService('agentId');
$messageService->setAccessToken($accessToken);
$messageService->setMessage('text-message'); // 设置发送的文本消息
$messageService->setSecrecy(1); // 设置消息是否保密 0-否 1-是
$messageService->sendTextMsgToCompanyUser('userId','userId','userId','userId','userId','userId','userId'); // 向多个/一个userId发送此消息
```

#### 如何获取external\_userid

[](#如何获取external_userid)

[通过成员userId获取](https://developer.work.weixin.qq.com/document/path/92113)[前端jsapi获取](https://developer.work.weixin.qq.com/document/path/91799)

#### 获取企业jsapi ticket

[](#获取企业jsapi-ticket)

[wx.config](https://developer.work.weixin.qq.com/document/path/94313)

```
$service = new WorkWechat\TicketService('corpId','secret');
$service->setAccessToken($accessToken);
$service->company();
// 刷新企业jsapi ticket
$service->refreshCompany()
```

#### 获取应用jsapi ticket

[](#获取应用jsapi-ticket)

[wx.agentConfig](https://developer.work.weixin.qq.com/document/path/94313)

```
$service = new WorkWechat\TicketService('corpId','secret');
$service->setAccessToken($accessToken);
$service->agent();
// 刷新应用jsapi ticket
$service->refreshCompany()
```

#### 明文corpid转换为加密corpid

[](#明文corpid转换为加密corpid)

[明文corpid转换为加密corpid](https://developer.work.weixin.qq.com/document/path/95604)

```
$service = new WorkWechat\TicketService('corpId','secret');
$service->setAccessToken($accessToken);
$service->openCorpId("corpid");
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

1426d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/471484c133ca595ad2a3270fbbb867f7809fca26a0de23cc65f7b8a984397baa?d=identicon)[Fucntion](/maintainers/Fucntion)

---

Top Contributors

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

---

Tags

work wechat

### Embed Badge

![Health badge](/badges/qingclouds-work-wechat-developer/health.svg)

```
[![Health](https://phpackages.com/badges/qingclouds-work-wechat-developer/health.svg)](https://phpackages.com/packages/qingclouds-work-wechat-developer)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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