Properties

Methods

__construct()

__construct(array  $options) 

Service constructor.

Parameters

array $options

getComonentTicket()

getComonentTicket() : boolean|array

接收公众平台推送的 Ticket

Throws

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

Returns

boolean|array

getComponentAccessToken()

getComponentAccessToken() : boolean|string

获取或刷新服务 AccessToken

Throws

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

Returns

boolean|string

getAuthorizerInfo()

getAuthorizerInfo(string  $authorizerAppid) : array

获取授权方的帐号基本信息

Parameters

string $authorizerAppid

授权公众号或小程序的appid

Throws

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

Returns

array

setAuthorization()

setAuthorization(string  $authorizerAppid, string  $funcscopeCategoryId, string  $confirmValue) : array

确认接受公众号将某权限集高级权限的授权

Parameters

string $authorizerAppid

授权公众号或小程序的appid

string $funcscopeCategoryId

权限集ID

string $confirmValue

是否确认(1.确认授权, 2.取消确认)

Throws

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

Returns

array

setAuthorizerOption()

setAuthorizerOption(string  $authorizerAppid, string  $optionName, string  $optionValue) : array

设置授权方的选项信息

Parameters

string $authorizerAppid

授权公众号或小程序的appid

string $optionName

选项名称

string $optionValue

设置的选项值

Throws

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

Returns

array

getAuthorizerOption()

getAuthorizerOption(string  $authorizerAppid, string  $optionName) : array

获取授权方的选项设置信息

Parameters

string $authorizerAppid

授权公众号或小程序的appid

string $optionName

选项名称

Throws

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

Returns

array

getPreauthCode()

getPreauthCode() : string

获取预授权码 pre_auth_code

Throws

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

Returns

string

getAuthRedirect()

getAuthRedirect(string  $redirectUri, integer  $authType = 3) : boolean

获取授权回跳地址

Parameters

string $redirectUri

回调URI

integer $authType

要授权的帐号类型

Throws

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

Returns

boolean

getQueryAuthorizerInfo()

getQueryAuthorizerInfo(null  $authCode = null) : boolean|array

使用授权码换取公众号或小程序的接口调用凭据和授权信息

Parameters

null $authCode

授权码

Throws

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

Returns

boolean|array

refreshAccessToken()

refreshAccessToken(string  $authorizerAppid, string  $authorizerRefreshToken) : array

获取(刷新)授权公众号的令牌

Parameters

string $authorizerAppid

授权公众号或小程序的appid

string $authorizerRefreshToken

授权方的刷新令牌

Throws

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

Returns

array

getOauthRedirect()

getOauthRedirect(string  $authorizerAppid, string  $redirectUri, string  $scope = 'snsapi_userinfo') : string

oauth 授权跳转接口

Parameters

string $authorizerAppid

授权公众号或小程序的appid

string $redirectUri

回调地址

string $scope

snsapi_userinfo|snsapi_base

Returns

string

getOauthAccessToken()

getOauthAccessToken(string  $authorizerAppid) : boolean|array

通过code获取AccessToken

Parameters

string $authorizerAppid

授权公众号或小程序的appid

Throws

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

Returns

boolean|array

getAuthorizerList()

getAuthorizerList(integer  $count = 500, integer  $offset) : array|boolean

取当前所有已授权的帐号基本信息

Parameters

integer $count

拉取数量,最大为500

integer $offset

偏移位置/起始位置

Throws

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

Returns

array|boolean

instance()

instance(string  $name, string  $authorizerAppid, string  $type = 'WeChat') : \WeChat\Card|\WeChat\Custom|\WeChat\Media|\WeChat\Menu|\WeChat\Oauth|\WeChat\Pay|\WeChat\Product|\WeChat\Qrcode|\WeChat\Receive|\WeChat\Scan|\WeChat\Script|\WeChat\Shake|\WeChat\Tags|\WeChat\Template|\WeChat\User|\WeChat\Wifi

创建指定授权公众号接口实例

Parameters

string $name

需要加载的接口实例名称

string $authorizerAppid

授权公众号的appid

string $type

加载SDK类型 WeChat|WeMini

Returns

\WeChat\Card|\WeChat\Custom|\WeChat\Media|\WeChat\Menu|\WeChat\Oauth|\WeChat\Pay|\WeChat\Product|\WeChat\Qrcode|\WeChat\Receive|\WeChat\Scan|\WeChat\Script|\WeChat\Shake|\WeChat\Tags|\WeChat\Template|\WeChat\User|\WeChat\Wifi

getConfig()

getConfig(string  $authorizerAppid) : array

获取授权公众号配置参数

Parameters

string $authorizerAppid

授权公众号的appid

Returns

array

httpPostForJson()

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

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

Parameters

string $url

接口地址

array $data

请求数据

boolean $buildToJson

Returns

array

httpGetForJson()

httpGetForJson(string  $url) : array

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

Parameters

string $url

接口地址

Returns

array