Constants

PREVIEW_BY_OPENID

PREVIEW_BY_OPENID = 'touser'

PREVIEW_BY_NAME

PREVIEW_BY_NAME = 'towxname'

Properties

$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

Methods

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

send()

send(array  $message) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Send a message.

Parameters

array $message

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

preview()

preview(array  $message) : array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string

Preview a message.

Parameters

array $message

Returns

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

delete()

delete(string  $msgId) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Delete a broadcast.

Parameters

string $msgId

Returns

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

status()

status(string  $msgId) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Get a broadcast status.

Parameters

string $msgId

Returns

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

sendText()

sendText(string  $message, mixed  $reception = null) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Send a text message.

Parameters

string $message
mixed $reception

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

sendNews()

sendNews(string  $mediaId, mixed  $reception = null) : array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string

Send a news message.

Parameters

string $mediaId
mixed $reception

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

sendVoice()

sendVoice(string  $mediaId, mixed  $reception = null) : array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string

Send a voice message.

Parameters

string $mediaId
mixed $reception

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

sendImage()

sendImage(mixed  $mediaId, mixed  $reception = null) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Send a image message.

Parameters

mixed $mediaId
mixed $reception

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

sendVideo()

sendVideo(string  $mediaId, mixed  $reception = null) : array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string

Send a video message.

Parameters

string $mediaId
mixed $reception

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

sendCard()

sendCard(string  $cardId, mixed  $reception = null) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Send a card message.

Parameters

string $cardId
mixed $reception

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

previewText()

previewText(mixed  $message, string  $reception, string  $method = self::PREVIEW_BY_OPENID) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Preview a text message.

Parameters

mixed $message

message

string $reception
string $method

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

previewNews()

previewNews(mixed  $mediaId, string  $reception, string  $method = self::PREVIEW_BY_OPENID) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Preview a news message.

Parameters

mixed $mediaId

message

string $reception
string $method

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

previewVoice()

previewVoice(mixed  $mediaId, string  $reception, string  $method = self::PREVIEW_BY_OPENID) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Preview a voice message.

Parameters

mixed $mediaId

message

string $reception
string $method

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

previewImage()

previewImage(mixed  $mediaId, string  $reception, string  $method = self::PREVIEW_BY_OPENID) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Preview a image message.

Parameters

mixed $mediaId

message

string $reception
string $method

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

previewVideo()

previewVideo(mixed  $mediaId, string  $reception, string  $method = self::PREVIEW_BY_OPENID) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Preview a video message.

Parameters

mixed $mediaId

message

string $reception
string $method

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

previewCard()

previewCard(mixed  $cardId, string  $reception, string  $method = self::PREVIEW_BY_OPENID) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Preview a card message.

Parameters

mixed $cardId

message

string $reception
string $method

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

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

previewMessage()

previewMessage(\EasyWeChat\Kernel\Contracts\MessageInterface  $message, mixed  $reception, string  $method = self::PREVIEW_BY_OPENID) : mixed

Parameters

\EasyWeChat\Kernel\Contracts\MessageInterface $message
mixed $reception
string $method

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

mixed

sendMessage()

sendMessage(\EasyWeChat\Kernel\Contracts\MessageInterface  $message, mixed  $reception = null) : mixed

Parameters

\EasyWeChat\Kernel\Contracts\MessageInterface $message
mixed $reception

Throws

\EasyWeChat\Kernel\Exceptions\RuntimeException

Returns

mixed

__call()

__call(string  $method, array  $args) : mixed

Parameters

string $method
array $args

Returns

mixed

previewTextByName()

previewTextByName(mixed  $text, mixed  $name) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

;

Parameters

mixed $text
mixed $name

Returns

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

previewNewsByName()

previewNewsByName(mixed  $mediaId, mixed  $name) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

;

Parameters

mixed $mediaId
mixed $name

Returns

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

previewVoiceByName()

previewVoiceByName(mixed  $mediaId, mixed  $name) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

;

Parameters

mixed $mediaId
mixed $name

Returns

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

previewImageByName()

previewImageByName(mixed  $mediaId, mixed  $name) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

;

Parameters

mixed $mediaId
mixed $name

Returns

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

previewVideoByName()

previewVideoByName(mixed  $message, mixed  $name) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

;

Parameters

mixed $message
mixed $name

Returns

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

previewCardByName()

previewCardByName(mixed  $cardId, mixed  $name) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

;

Parameters

mixed $cardId
mixed $name

Returns

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

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