PHPackages                             weiwork/weiworkapi - 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. weiwork/weiworkapi

ActiveLibrary

weiwork/weiworkapi
==================

转载,侵删

v2.0(5y ago)013Apache-2.0PHPPHP &gt;=5.3.3,&lt;=7.2.0

Since Apr 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/tcxuexi/weiworkapi)[ Packagist](https://packagist.org/packages/weiwork/weiworkapi)[ Docs](https://github.com/sbzhu/weworkapi_php)[ RSS](/packages/weiwork-weiworkapi/feed)WikiDiscussions main Synced 6d ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

About
=====

[](#about)

weworkapi\_php 是为了简化开发者对企业微信API接口的使用而设计的，API调用库系列之php版本
包括企业API接口、消息回调处理方法、第三方开放接口等
本库仅做示范用，并不保证完全无bug；
另外，作者会不定期更新本库，但不保证与官方API接口文档同步，因此一切以[官方文档](https://work.weixin.qq.com/api/doc)为准。

更多来自个人开发者的其它语言的库推荐：
python : [https://github.com/sbzhu/weworkapi\_python](https://github.com/sbzhu/weworkapi_python) (企业微信团队)
ruby ：  MyColorway(个人开发者)
php : [https://github.com/sbzhu/weworkapi\_php](https://github.com/sbzhu/weworkapi_php) (企业微信团队)
golang : [https://github.com/sbzhu/weworkapi\_golang](https://github.com/sbzhu/weworkapi_golang) (企业微信团队)
golang :  (个人开发者)

Requirement
===========

[](#requirement)

经测试，PHP 5.3.3 ~ 7.2.0 版本均可使用

Director
========

[](#director)

├── api // API 接口
│ ├── datastructure // API接口需要使用到的一些数据结构
│ ├── examples // API接口的测试用例
│ ├── README.md
│ └── src // API接口的关键逻辑
├── callback // 消息回调的一些方法
├── config.php
├── README.md
└── utils // 一些基础方法

Usage
=====

[](#usage)

将本项目下载到你的目录，既可直接引用相关文件

```
include_once("api/src/CorpAPI.class.php");

// 实例化 API 类
$api = new CorpAPI($corpId='ww55ca070cb9b7eb22', $secret='ktmzrVIlUH0UW63zi7-JyzsgTL9NfwUhHde6or6zwQY');

try {
    // 创建 User
    $user = new User();
    {
        $user->userid = "userid";
        $user->name = "name";
        $user->mobile = "131488888888";
        $user->email = "sbzhu@ipp.cas.cn";
        $user->department = array(1);
    }
    $api->UserCreate($user);

    // 获取User
    $user = $api->UserGet("userid");

    // 删除User
    $api->UserDelete("userid");
} catch {
    echo $e->getMessage() . "\n";
    $api->UserDelete("userid");
}

```

详细使用方法参考每个模块下的测试用例

关于token的缓存
==========

[](#关于token的缓存)

token是需要缓存的，不能每次调用都去获取token，[否则会中频率限制](https://work.weixin.qq.com/api/doc#10013/%E7%AC%AC%E5%9B%9B%E6%AD%A5%EF%BC%9A%E7%BC%93%E5%AD%98%E5%92%8C%E5%88%B7%E6%96%B0access_token)
在本库的设计里，token是以类里的一个变量缓存的
比如api/src/CorpAPI.class.php 里的$accessToken变量
在类的生命周期里，这个accessToken都是存在的， 当且仅当发现token过期，CorpAPI类会自动刷新token
刷新机制在 api/src/API.class.php
所以，使用时，只需要全局实例化一个CorpAPI类，不要析构它，就可一直用它调函数，不用关心 token

```
$api = new CorpAPI(corpid, corpsecret);
$api->dosomething()
$api->dosomething()
$api->dosomething()
....

```

当然，如果要更严格的做的话，建议自行修改，`全局缓存token，比如存redis、存文件等`，失效周期设置为2小时。

Contact us
==========

[](#contact-us)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.5% 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 ~0 days

Total

2

Last Release

1854d ago

Major Versions

v1.0 → v2.02021-04-19

### Community

Maintainers

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

---

Top Contributors

[![sbzhu](https://avatars.githubusercontent.com/u/17812827?v=4)](https://github.com/sbzhu "sbzhu (86 commits)")[![tcxuexi](https://avatars.githubusercontent.com/u/56192326?v=4)](https://github.com/tcxuexi "tcxuexi (2 commits)")[![daidi](https://avatars.githubusercontent.com/u/4158851?v=4)](https://github.com/daidi "daidi (1 commits)")[![fenzaikai](https://avatars.githubusercontent.com/u/24308690?v=4)](https://github.com/fenzaikai "fenzaikai (1 commits)")[![wei4126](https://avatars.githubusercontent.com/u/29363989?v=4)](https://github.com/wei4126 "wei4126 (1 commits)")[![xiaoyouxi01](https://avatars.githubusercontent.com/u/36061058?v=4)](https://github.com/xiaoyouxi01 "xiaoyouxi01 (1 commits)")

---

Tags

phpweworkwork

### Embed Badge

![Health badge](/badges/weiwork-weiworkapi/health.svg)

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

###  Alternatives

[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)

PHPackages © 2026

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