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

session()

session(string  $appid, string  $code) : mixed

code换取session_key

Parameters

string $appid

小程序的AppID

string $code

登录时获取的code

Throws

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

Returns

mixed

getCopyRegisterMiniUrl()

getCopyRegisterMiniUrl(string  $authorizerAppid, integer  $copyWxVerify, string  $redirectUri) : string

1.注册流程及接口说明

Parameters

string $authorizerAppid

公众号的appid

integer $copyWxVerify

是否复用公众号的资质进行微信认证(1:申请复用资质进行微信 认证 0:不申请)

string $redirectUri

用户扫码授权后,MP 扫码页面将跳转到该地址(注:1.链接需 urlencode 2.Host 需和第三方平台在微信开放平台上面填写的登 录授权的发起页域名一致)

Returns

string

getComponentreBindAdmin()

getComponentreBindAdmin(string  $authorizerAppid, string  $redirectUri) : string

2.7.1 从第三方平台跳转至微信公众平台授权注册页面

Parameters

string $authorizerAppid

公众号的 appid

string $redirectUri

新管理员信息填写完成点击提交后,将跳转到该地址

Returns

string

getTemplateDraftList()

getTemplateDraftList() : array

1、获取草稿箱内的所有临时代码草稿

Throws

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

Returns

array

getTemplateList()

getTemplateList() : array

2、获取代码模版库中的所有小程序代码模版

Throws

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

Returns

array

addToTemplate()

addToTemplate(integer  $draft_id) : array

3、将草稿箱的草稿选为小程序代码模版

Parameters

integer $draft_id

草稿ID,本字段可通过“ 获取草稿箱内的所有临时代码草稿 ”接口获得

Throws

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

Returns

array

deleteTemplate()

deleteTemplate(integer  $template_id) : array

4、删除指定小程序代码模版

Parameters

integer $template_id

要删除的模版ID

Throws

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

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