Constants

USER_DEFINED_HANDLER

USER_DEFINED_HANDLER = 'userDefined'

Used to identify handler defined by client code Maybe useful in the future.

Properties

$middlewares

$middlewares : array

The middlewares.

Type

array

$globals

$globals : array

Type

array

$defaults

$defaults : array

Guzzle client default settings.

Type

array

Methods

setDefaultOptions()

setDefaultOptions(array  $defaults = array()) 

Set guzzle default settings.

Parameters

array $defaults

getDefaultOptions()

getDefaultOptions() : array

Return current guzzle default settings.

Returns

array

get()

get(string  $url, array  $options = array()) : \Psr\Http\Message\ResponseInterface

GET request.

Parameters

string $url
array $options

Throws

\EasyWeChat\Core\Exceptions\HttpException

Returns

\Psr\Http\Message\ResponseInterface

post()

post(string  $url, array|string  $options = array()) : \Psr\Http\Message\ResponseInterface

POST request.

Parameters

string $url
array|string $options

Throws

\EasyWeChat\Core\Exceptions\HttpException

Returns

\Psr\Http\Message\ResponseInterface

json()

json(string  $url, string|array  $options = array(), integer  $encodeOption = JSON_UNESCAPED_UNICODE, array  $queries = array()) : \Psr\Http\Message\ResponseInterface

JSON request.

Parameters

string $url
string|array $options
integer $encodeOption
array $queries

Throws

\EasyWeChat\Core\Exceptions\HttpException

Returns

\Psr\Http\Message\ResponseInterface

upload()

upload(string  $url, array  $files = array(), array  $form = array(), array  $queries = array()) : \Psr\Http\Message\ResponseInterface

Upload file.

Parameters

string $url
array $files
array $form
array $queries

Throws

\EasyWeChat\Core\Exceptions\HttpException

Returns

\Psr\Http\Message\ResponseInterface

getClient()

getClient() : \GuzzleHttp\Client

Return GuzzleHttp\Client instance.

Returns

\GuzzleHttp\Client

addMiddleware()

addMiddleware(callable  $middleware) : $this

Add a middleware.

Parameters

callable $middleware

Returns

$this

getMiddlewares()

getMiddlewares() : array

Return all middlewares.

Returns

array

request()

request(string  $url, string  $method = 'GET', array  $options = array()) : \Psr\Http\Message\ResponseInterface

Make a request.

Parameters

string $url
string $method
array $options

Throws

\EasyWeChat\Core\Exceptions\HttpException

Returns

\Psr\Http\Message\ResponseInterface

parseJSON()

parseJSON(\Psr\Http\Message\ResponseInterface|string  $body) : mixed

Parameters

\Psr\Http\Message\ResponseInterface|string $body

Throws

\EasyWeChat\Core\Exceptions\HttpException

Returns

mixed

fuckTheWeChatInvalidJSON()

fuckTheWeChatInvalidJSON(\Psr\Http\Message\StreamInterface|string  $invalidJSON) : string

Filter the invalid JSON string.

Parameters

\Psr\Http\Message\StreamInterface|string $invalidJSON

Returns

string