Constants

GET

GET = 'get'

POST

POST = 'post'

JSON

JSON = 'json'

API_GET

API_GET = 'https://api.weixin.qq.com/cgi-bin/media/get'

API_UPLOAD

API_UPLOAD = 'https://api.weixin.qq.com/cgi-bin/media/upload'

Properties

$maxRetries

$maxRetries : integer

Type

integer

$allowTypes

$allowTypes : array

Allow media type.

Type

array

Methods

setHttp()

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

Set the http instance.

Parameters

\EasyWeChat\Core\Http $http

Returns

$this

setAccessToken()

setAccessToken(\EasyWeChat\Core\AccessToken  $accessToken) : $this

Set the request token.

Parameters

\EasyWeChat\Core\AccessToken $accessToken

Returns

$this

maxRetries()

maxRetries(integer  $retries) 

Parameters

integer $retries

parseJSON()

parseJSON(string  $method, array  $args) : \EasyWeChat\Support\Collection

Parse JSON from response and check error.

Parameters

string $method
array $args

Returns

\EasyWeChat\Support\Collection

download()

download(string  $mediaId, string  $directory, string  $filename = '') : string

Download temporary material.

Parameters

string $mediaId
string $directory
string $filename

Throws

\EasyWeChat\Core\Exceptions\InvalidArgumentException

Returns

string

getStream()

getStream(string  $mediaId) : mixed

Fetch item from WeChat server.

Parameters

string $mediaId

Throws

\EasyWeChat\Core\Exceptions\RuntimeException

Returns

mixed

upload()

upload(string  $type, string  $path) : \EasyWeChat\Support\Collection

Upload temporary material.

Parameters

string $type
string $path

Throws

\EasyWeChat\Core\Exceptions\InvalidArgumentException

Returns

\EasyWeChat\Support\Collection

uploadImage()

uploadImage(  $path) : \EasyWeChat\Support\Collection

Upload image.

Parameters

$path

Throws

\EasyWeChat\Core\Exceptions\InvalidArgumentException

Returns

\EasyWeChat\Support\Collection

uploadVideo()

uploadVideo(  $path) : \EasyWeChat\Support\Collection

Upload video.

Parameters

$path

Throws

\EasyWeChat\Core\Exceptions\InvalidArgumentException

Returns

\EasyWeChat\Support\Collection

uploadVoice()

uploadVoice(  $path) : \EasyWeChat\Support\Collection

Upload voice.

Parameters

$path

Throws

\EasyWeChat\Core\Exceptions\InvalidArgumentException

Returns

\EasyWeChat\Support\Collection

uploadThumb()

uploadThumb(  $path) : \EasyWeChat\Support\Collection

Upload thumb.

Parameters

$path

Throws

\EasyWeChat\Core\Exceptions\InvalidArgumentException

Returns

\EasyWeChat\Support\Collection

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

checkAndThrow()

checkAndThrow(array  $contents) 

Check the array data errors, and Throw exception when the contents contains error.

Parameters

array $contents

Throws

\EasyWeChat\Core\Exceptions\HttpException