Constants

URL_PREFIX

URL_PREFIX = 'https://api.weixin.qq.com/cgi-bin/component'

COMPONENT_TOKEN_URL

COMPONENT_TOKEN_URL = '/api_component_token'

REFRESH_ACCESS_TOKEN

REFRESH_ACCESS_TOKEN = '/api_authorizer_token'

PREAUTH_CODE_URL

PREAUTH_CODE_URL = '/api_create_preauthcode'

QUERY_AUTH_URL

QUERY_AUTH_URL = '/api_query_auth'

GET_AUTHORIZER_INFO_URL

GET_AUTHORIZER_INFO_URL = '/api_get_authorizer_info'

GET_AUTHORIZER_OPTION_URL

GET_AUTHORIZER_OPTION_URL = '/api_get_authorizer_option'

SET_AUTHORIZER_OPTION_URL

SET_AUTHORIZER_OPTION_URL = '/api_set_authorizer_option'

Properties

$errCode

$errCode : 

Type

$errMsg

$errMsg : 

Type

$component_verify_ticket

$component_verify_ticket : 

Type

$component_appid

$component_appid : 

Type

$component_appsecret

$component_appsecret : 

Type

$component_token

$component_token : 

Type

$component_encodingaeskey

$component_encodingaeskey : 

Type

$component_access_token

$component_access_token : 

Type

$authorizer_appid

$authorizer_appid : 

Type

$pre_auth_code

$pre_auth_code : 

Type

$data

$data : 

Type

Methods

__construct()

__construct(array  $options = array()) 

WechatService constructor.

Parameters

array $options

getComonentTicket()

getComonentTicket() : boolean|array

接收公众平台推送的 Ticket

Returns

boolean|array

refreshAccessToken()

refreshAccessToken(string  $authorizer_appid, string  $authorizer_refresh_token) : boolean|string

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

Parameters

string $authorizer_appid

授权方APPID

string $authorizer_refresh_token

授权方刷新令牌

Returns

boolean|string

getComponentAccessToken()

getComponentAccessToken() : boolean|string

获取或刷新服务 AccessToken

Returns

boolean|string

getAuthorizationInfo()

getAuthorizationInfo(string  $authorization_code) : boolean|array

获取公众号的授权信息

Parameters

string $authorization_code

Returns

boolean|array

getWechatInfo()

getWechatInfo(string  $authorizer_appid) : boolean

获取授权方的账户信息

Parameters

string $authorizer_appid

Returns

boolean

getAuthorizerOption()

getAuthorizerOption(string  $authorizer_appid, string  $option_name) : boolean

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

Parameters

string $authorizer_appid
string $option_name

Returns

boolean

setAuthorizerOption()

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

设置授权方的选项信息

Parameters

string $authorizer_appid
string $option_name
string $option_value

Returns

boolean

getAuthRedirect()

getAuthRedirect(string  $redirect_uri) : boolean

获取授权回跳地址

Parameters

string $redirect_uri

Returns

boolean

getPreauthCode()

getPreauthCode() : boolean|string

获取预授权码

Returns

boolean|string

getOauthRedirect()

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

oauth 授权跳转接口

Parameters

string $appid
string $redirect_uri
string $scope

snsapi_userinfo|snsapi_base

Returns

string

getOauthAccessToken()

getOauthAccessToken(string  $appid) : boolean|array

通过code获取Access Token

Parameters

string $appid

Returns

boolean|array

getOauthUserInfo()

getOauthUserInfo(string  $openid, string  $oauthAccessToken) : boolean|array

获取关注者详细信息

Parameters

string $openid
string $oauthAccessToken

Returns

boolean|array —

{subscribe,openid,nickname,sex,city,province,country,language,headimgurl,subscribe_time,[unionid]} 注意:unionid字段 只有在用户将公众号绑定到公众号第三方平台账号后,才会出现。建议调用前用isset()检测一下

_decode()

_decode(string  $result, string|null  $field = null) : boolean|array

解析JSON数据

Parameters

string $result
string|null $field

Returns

boolean|array

_parseFuncInfo()

_parseFuncInfo(array  $func_info) : string

解析授权信息,返回以逗号分割的数据

Parameters

array $func_info

Returns

string

parseJson()

parseJson(string  $result) : boolean

解析JSON数据

Parameters

string $result

Returns

boolean