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  $authorizer_appid) : array

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

Parameters

string $authorizer_appid

授权公众号或小程序的appid

Throws

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

Returns

array

setAuthorizerOption()

setAuthorizerOption(string  $authorizer_appid, string  $option_name, string  $option_value) : array

设置授权方的选项信息

Parameters

string $authorizer_appid

授权公众号或小程序的appid

string $option_name

选项名称

string $option_value

设置的选项值

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  $redirect_uri, integer  $auth_type = 3) : boolean

获取授权回跳地址

Parameters

string $redirect_uri

回调URI

integer $auth_type

要授权的帐号类型

Throws

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

Returns

boolean

getQueryAuthorizerInfo()

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

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

Parameters

null $auth_code

授权码

Throws

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

Returns

boolean|array

refreshAccessToken()

refreshAccessToken(string  $authorizer_appid, string  $authorizer_refresh_token) : array

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

Parameters

string $authorizer_appid

授权公众号或小程序的appid

string $authorizer_refresh_token

授权方的刷新令牌

Throws

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

Returns

array

getOauthRedirect()

getOauthRedirect(string  $authorizer_appid, string  $redirect_uri, string  $scope = 'snsapi_userinfo') : string

oauth 授权跳转接口

Parameters

string $authorizer_appid

授权公众号或小程序的appid

string $redirect_uri

回调地址

string $scope

snsapi_userinfo|snsapi_base

Returns

string

getOauthAccessToken()

getOauthAccessToken(string  $authorizer_appid) : boolean|array

通过code获取AccessToken

Parameters

string $authorizer_appid

授权公众号或小程序的appid

Throws

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

Returns

boolean|array

instance()

instance(string  $type, string  $authorizer_appid) : \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 $type

需要加载的接口实例名称

string $authorizer_appid

授权公众号的appid

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  $authorizer_appid) : array

获取授权公众号配置参数

Parameters

string $authorizer_appid

授权公众号的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