Properties

$access_token

$access_token : string

访问AccessToken

Type

string

$currentMethod

$currentMethod : array

当前请求方法参数

Type

array

$isTry

$isTry : boolean

当前模式

Type

boolean

$GetAccessTokenCallback

$GetAccessTokenCallback : string

注册代替函数

Type

string

Methods

__construct()

__construct(array  $options) 

BasicWeChat constructor.

Parameters

array $options

getAccessToken()

getAccessToken() : string

获取访问accessToken

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

string

delAccessToken()

delAccessToken() : boolean

清理删除accessToken

Returns

boolean

callPostApi()

callPostApi(string  $url, array  $data, boolean  $isBuildJson = true) : array

接口通用POST请求方法

Parameters

string $url

接口URL

array $data

POST提交接口参数

boolean $isBuildJson

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

callGetApi()

callGetApi(string  $url) : array

接口通用GET请求方法

Parameters

string $url

接口URL

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

addAccount()

addAccount(string  $kf_account, string  $nickname, string  $password) : array

添加客服帐号

Parameters

string $kf_account

客服账号

string $nickname

客服昵称

string $password

账号密码

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

updateAccount()

updateAccount(string  $kf_account, string  $nickname, string  $password) : array

修改客服帐号

Parameters

string $kf_account

客服账号

string $nickname

客服昵称

string $password

账号密码

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

deleteAccount()

deleteAccount(string  $kf_account, string  $nickname, string  $password) : array

删除客服帐号

Parameters

string $kf_account

客服账号

string $nickname

客服昵称

string $password

账号密码

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

inviteworker()

inviteworker(string  $kf_account, string  $invite_wx) : array

邀请绑定客服帐号

Parameters

string $kf_account

完整客服帐号,格式为:帐号前缀@公众号微信号

string $invite_wx

接收绑定邀请的客服微信号

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

getAccountList()

getAccountList() : array

获取所有客服账号

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

uploadHeadimg()

uploadHeadimg(string  $kf_account, string  $image) : array

设置客服帐号的头像

Parameters

string $kf_account

客户账号

string $image

头像文件位置

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

send()

send(array  $data) : array

客服接口-发消息

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

typing()

typing(string  $openid, string  $command = 'Typing') : array

客服输入状态

Parameters

string $openid

普通用户(openid)

string $command

Typing:正在输入,CancelTyping:取消正在输入

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

massSendAll()

massSendAll(array  $data) : array

根据标签进行群发【订阅号与服务号认证后均可用】

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

massSend()

massSend(array  $data) : array

根据OpenID列表群发【订阅号不可用,服务号认证后可用】

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

massDelete()

massDelete(integer  $msg_id, null|integer  $article_idx = null) : array

删除群发【订阅号与服务号认证后均可用】

Parameters

integer $msg_id

发送出去的消息ID

null|integer $article_idx

要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

massPreview()

massPreview(array  $data) : array

预览接口【订阅号与服务号认证后均可用】

Parameters

array $data

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

massGet()

massGet(integer  $msg_id) : array

查询群发消息发送状态【订阅号与服务号认证后均可用】

Parameters

integer $msg_id

群发消息后返回的消息id

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

massGetSeed()

massGetSeed() : array

获取群发速度

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

massSetSeed()

massSetSeed(integer  $speed) : array

设置群发速度

Parameters

integer $speed

群发速度的级别

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

httpGetForJson()

httpGetForJson(string  $url) : array

以GET获取接口数据并转为数组

Parameters

string $url

接口地址

Throws

\WeChat\Exceptions\InvalidResponseException

Returns

array

httpPostForJson()

httpPostForJson(string  $url, array  $data, boolean  $buildToJson = true) : array

以POST获取接口数据并转为数组

Parameters

string $url

接口地址

array $data

请求数据

boolean $buildToJson

Throws

\WeChat\Exceptions\InvalidResponseException

Returns

array

registerApi()

registerApi(string  $url, string  $method, array  $arguments = array()) : mixed

注册当前请求接口

Parameters

string $url

接口地址

string $method

当前接口方法

array $arguments

请求参数

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

mixed