PHPackages                             min-radish/php-wechat-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. [API Development](/categories/api)
4. /
5. min-radish/php-wechat-api

ActiveLibrary[API Development](/categories/api)

min-radish/php-wechat-api
=========================

PHP对微信公众号API的调用

v1.4.3(7y ago)1351MITPHPPHP &gt;=5.0.0

Since Mar 19Pushed 4y agoCompare

[ Source](https://github.com/MinRadish/radish-php-wechat-api)[ Packagist](https://packagist.org/packages/min-radish/php-wechat-api)[ RSS](/packages/min-radish-php-wechat-api/feed)WikiDiscussions master Synced 3d ago

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

php对微信公众号的API的调用
================

[](#php对微信公众号的api的调用)

*需自定义一个类并继承 Radish\\WeChat\\WeChat 自定义CaChe抽象方法*
**public function cacheGet($key = 'access\_token', $default = false);**
**public function cacheSet($key, $val, $timeout = 7140);**

api示例说明
-------

[](#api示例说明)

```
    $wechat = new WeChat();

```

### 获取客服列表

[](#获取客服列表)

```
$json = $wechat->getCSList();
正确响应
{
    "kf_list" : [
         {
            "kf_account" : "test1@test",
            "kf_headimgurl" : "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjfUS8Ym0GSaLic0FD3vN0V8PILcibEGb2fPfEOmw/0",
            "kf_id" : "1001",
            "kf_nick" : "ntest1",
            "kf_wx" : "kfwx1"
         },
         {
            "kf_account" : "test2@test",
            "kf_headimgurl" : "http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjfUS8Ym0GSaLic0FD3vN0V8PILcibEGb2fPfEOmw/0",
            "kf_id" : "1002",
            "kf_nick" : "ntest2",
            "kf_wx" : "kfwx2"
         }
    ]
}

```

参数说明kf\_account完整客服帐号，格式为：帐号前缀@公众号微信号kf\_nick客服昵称kf\_id客服编号kf\_headimgurl客服头像kf\_wx如果客服帐号已绑定了客服人员微信号， 则此处显示微信号invite\_wx如果客服帐号尚未绑定微信号，但是已经发起了一个绑定邀请， 则此处显示绑定邀请的微信号invite\_expire\_time如果客服帐号尚未绑定微信号，但是已经发起过一个绑定邀请， 邀请的过期时间，为unix 时间戳invite\_status邀请的状态，有等待确认“waiting”，被拒绝“rejected”， 过期“expired”### 获取在线客服列表

[](#获取在线客服列表)

```
$json = $wechat->getOLCSList();
返回数据示例（正确时的JSON返回结果）：
 {
     "kf_online_list" : [
         {
             "kf_account" : "test1@test" ,
              "status" : 1,
              "kf_id" : "1001" ,
              "accepted_case" : 1
         },
         {
             "kf_account" : "test2@test" ,
              "status" : 1,
              "kf_id" : "1002" ,
              "accepted_case" : 2
         }
     ]
 }

```

参数说明

参数说明kf\_account完整客服帐号，格式为：帐号前缀@公众号微信号status客服在线状态，目前为：1、web 在线kf\_id客服编号accepted\_case客服当前正在接待的会话数### 添加客服帐号

[](#添加客服帐号)

```
$json = $wechat->addCS($param);
$param 示例
{
    "kf_account" : "test1@test",
    "nickname" : "客服1"
}

```

参数说明kf\_account完整客服帐号，格式为：帐号前缀@公众号微信号，帐号前缀最多10个字符，必须是英文、数字字符或者下划线，后缀为公众号微信号，长度不超过30个字符nickname客服昵称，最长16个字返回数据示例（正确时的JSON返回结果）： { "errcode" : 0, "errmsg" : "ok" }

### 邀请绑定客服帐号

[](#邀请绑定客服帐号)

*$json = $wechat-&gt;invitBindCS($param);*

```
$param 示例
{
    "kf_account" : "test1@test",
    "invite_wx" : "test_kfwx"
}

```

参数说明

参数说明kf\_account完整客服帐号，格式为：帐号前缀@公众号微信号invite\_wx接收绑定邀请的客服微信号### 设置客服信息

[](#设置客服信息)

*$json = $wechat-&gt;updateCS($param);*

```
$param示例
{
    "kf_account" : "test1@test",
    "nickname" : "客服1"
}

```

参数说明

参数说明kf\_account完整客服帐号，格式为：帐号前缀@公众号微信号nickname客服昵称，最长16个字### 上传客服头像

[](#上传客服头像)

*$json = $wechat-&gt;updateCSImg($CSAccount, $param);*

*$CSAccount完整客服帐号，格式为：帐号前缀@公众号微信号*

```
$file = 文件绝对路径;
$param
[
  'media' => new \CURLFile($file)
]

```

### 删除客服帐号

[](#删除客服帐号)

*$json = $wechat-&gt;updateCSImg($CSAccount);*

*$CSAccount完整客服帐号，格式为：帐号前缀@公众号微信号*

客服管理接口返回码说明
-----------

[](#客服管理接口返回码说明)

返回码说明0成功65400API不可用，即没有开通/升级到新版客服功能65401无效客服帐号65403客服昵称不合法65404客服帐号不合法65405帐号数目已达到上限，不能继续添加65406已经存在的客服帐号65407邀请对象已经是该公众号客服65408本公众号已经有一个邀请给该微信65409无效的微信号65410邀请对象绑定公众号客服数达到上限（目前每个微信号可以绑定5个公众号客服帐号）65411该帐号已经有一个等待确认的邀请，不能重复邀请65412该帐号已经绑定微信号，不能进行邀请40005不支持的媒体类型40009媒体文件长度不合法

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

8

Last Release

2584d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/354ed9bfa439a57b040570fe37efa954208038eeb19a3e8f5906498ca07d1d62?d=identicon)[PerfectMM](/maintainers/PerfectMM)

---

Top Contributors

[![MinRadish](https://avatars.githubusercontent.com/u/22492914?v=4)](https://github.com/MinRadish "MinRadish (45 commits)")

---

Tags

phpwechatphpapiwechat

### Embed Badge

![Health badge](/badges/min-radish-php-wechat-api/health.svg)

```
[![Health](https://phpackages.com/badges/min-radish-php-wechat-api/health.svg)](https://phpackages.com/packages/min-radish-php-wechat-api)
```

###  Alternatives

[jstolpe/instagram-graph-api-php-sdk

Instagram Graph API PHP SDK

13998.4k2](/packages/jstolpe-instagram-graph-api-php-sdk)

PHPackages © 2026

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