Constants

API_TOKEN_GET

API_TOKEN_GET = 'https://api.weixin.qq.com/cgi-bin/token'

Properties

$appId

$appId : string

App ID.

Type

string

$secret

$secret : string

App secret.

Type

string

$cacheKey

$cacheKey : string

Cache Key.

Type

string

$queryName

$queryName : string

Query name.

Type

string

$tokenJsonKey

$tokenJsonKey : string

Response Json key name.

Type

string

$prefix

$prefix : string

Cache key prefix.

Type

string

Methods

__construct()

__construct(string  $appId, string  $secret, \Doctrine\Common\Cache\Cache  $cache = null) 

Constructor.

Parameters

string $appId
string $secret
\Doctrine\Common\Cache\Cache $cache

getToken()

getToken(boolean  $forceRefresh = false) : string

Get token from WeChat API.

Parameters

boolean $forceRefresh

Returns

string

setToken()

setToken(string  $token, integer  $expires = 7200) : $this

设置自定义 token.

Parameters

string $token
integer $expires

Returns

$this

getAppId()

getAppId() : string

Return the app id.

Returns

string

getSecret()

getSecret() : string

Return the secret.

Returns

string

setQueryName()

setQueryName(string  $queryName) : $this

Set the query name.

Parameters

string $queryName

Returns

$this

getQueryName()

getQueryName() : string

Return the query name.

Returns

string

getQueryFields()

getQueryFields() : array

Return the API request queries.

Returns

array

getTokenFromServer()

getTokenFromServer() : string

Get the access token from WeChat server.

Throws

\EasyWeChat\Core\Exceptions\HttpException

Returns

string

setHttp()

setHttp(\EasyWeChat\Core\Http  $http) : $this

Set the http instance.

Parameters

\EasyWeChat\Core\Http $http

Returns

$this

setPrefix()

setPrefix(string  $prefix) : $this

Set the access token prefix.

Parameters

string $prefix

Returns

$this

setCacheKey()

setCacheKey(string  $cacheKey) : $this

Set access token cache key.

Parameters

string $cacheKey

Returns

$this

getCacheKey()

getCacheKey() : string

Get access token cache key.

Returns

string —

$this->cacheKey