Properties

$cache

$cache : \Psr\SimpleCache\CacheInterface

Type

\Psr\SimpleCache\CacheInterface

$baseUri

$baseUri : 

Type

$httpClient

$httpClient : \GuzzleHttp\ClientInterface

Type

\GuzzleHttp\ClientInterface

$middlewares

$middlewares : array

Type

array

$handlerStack

$handlerStack : \GuzzleHttp\HandlerStack

Type

\GuzzleHttp\HandlerStack

$defaults

$defaults : array

Type

array

$ticketEndpoint

$ticketEndpoint : string

Type

string

$url

$url : string

Current URI.

Type

string

Methods

getCache()

getCache() : \Psr\SimpleCache\CacheInterface

Get cache instance.

Returns

\Psr\SimpleCache\CacheInterface

setCache()

setCache(\Psr\SimpleCache\CacheInterface  $cache) : $this

Set cache instance.

Parameters

\Psr\SimpleCache\CacheInterface $cache

Returns

$this

httpGet()

httpGet(string  $url, array  $query = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

GET request.

Parameters

string $url
array $query

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

httpPost()

httpPost(string  $url, array  $data = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

POST request.

Parameters

string $url
array $data

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

httpPostJson()

httpPostJson(string  $url, string|array  $data = array(), array  $query = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

JSON request.

Parameters

string $url
string|array $data
array $query

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

httpUpload()

httpUpload(string  $url, array  $files = array(), array  $form = array(), array  $query = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Upload file.

Parameters

string $url
array $files
array $form
array $query

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

request()

request(string  $url, string  $method = 'GET', array  $options = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Make a request.

Parameters

string $url
string $method
array $options

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

requestRaw()

requestRaw(string  $url, string  $method = 'GET', array  $options = array()) : \EasyWeChat\Kernel\Http\Response

Parameters

string $url
string $method
array $options

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\EasyWeChat\Kernel\Http\Response

getHttpClient()

getHttpClient() : \GuzzleHttp\ClientInterface

Return GuzzleHttp\ClientInterface instance.

Returns

\GuzzleHttp\ClientInterface

setDefaultOptions()

setDefaultOptions(array  $defaults = array()) 

Set guzzle default settings.

Parameters

array $defaults

getDefaultOptions()

getDefaultOptions() : array

Return current guzzle default settings.

Returns

array

setHttpClient()

setHttpClient(\GuzzleHttp\ClientInterface  $httpClient) : $this

Set GuzzleHttp\Client.

Parameters

\GuzzleHttp\ClientInterface $httpClient

Returns

$this

pushMiddleware()

pushMiddleware(callable  $middleware, null|string  $name = null) : $this

Add a middleware.

Parameters

callable $middleware
null|string $name

Returns

$this

getMiddlewares()

getMiddlewares() : array

Return all middlewares.

Returns

array

setHandlerStack()

setHandlerStack(\GuzzleHttp\HandlerStack  $handlerStack) : $this

Parameters

\GuzzleHttp\HandlerStack $handlerStack

Returns

$this

getHandlerStack()

getHandlerStack() : \GuzzleHttp\HandlerStack

Build a handler stack.

Returns

\GuzzleHttp\HandlerStack

buildConfig()

buildConfig(array  $jsApiList, boolean  $debug = false, boolean  $beta = false, boolean  $json = true) : array|string

Get config json for jsapi.

Parameters

array $jsApiList
boolean $debug
boolean $beta
boolean $json

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException
\Psr\SimpleCache\InvalidArgumentException

Returns

array|string

getConfigArray()

getConfigArray(array  $apis, boolean  $debug = false, boolean  $beta = false) : array

Return jsapi config as a PHP array.

Parameters

array $apis
boolean $debug
boolean $beta

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException
\Psr\SimpleCache\InvalidArgumentException

Returns

array

getTicket()

getTicket(boolean  $refresh = false, string  $type = 'jsapi') : array|null

Get js ticket.

Parameters

boolean $refresh
string $type

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException
\Psr\SimpleCache\InvalidArgumentException

Returns

array|null

getTicketSignature()

getTicketSignature(string  $ticket, string  $nonce, integer  $timestamp, string  $url) : string

Sign the params.

Parameters

string $ticket
string $nonce
integer $timestamp
string $url

Returns

string

dictionaryOrderSignature()

dictionaryOrderSignature() : string

Returns

string

setUrl()

setUrl(string  $url) : $this

Set current url.

Parameters

string $url

Returns

$this

getUrl()

getUrl() : string

Get current url.

Returns

string

createDefaultCache()

createDefaultCache() : \Symfony\Component\Cache\Simple\FilesystemCache

Returns

\Symfony\Component\Cache\Simple\FilesystemCache

registerHttpMiddlewares()

registerHttpMiddlewares() 

Register Guzzle middlewares.

accessTokenMiddleware()

accessTokenMiddleware() : \Closure

Attache access token to request query.

Returns

\Closure

logMiddleware()

logMiddleware() : \Closure

Log the request.

Returns

\Closure

retryMiddleware()

retryMiddleware() : \Closure

Return retry middleware.

Returns

\Closure

fixJsonIssue()

fixJsonIssue(array  $options) : array

Parameters

array $options

Returns

array

configSignature()

configSignature(string|null  $url = null, string|null  $nonce = null, integer|null  $timestamp = null) : array

Build signature.

Parameters

string|null $url
string|null $nonce
integer|null $timestamp

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException
\Psr\SimpleCache\InvalidArgumentException

Returns

array

getAppId()

getAppId() : string

Returns

string