Constants

GET

GET = 'get'

POST

POST = 'post'

JSON

JSON = 'json'

API_GET

API_GET = 'https://api.weixin.qq.com/cgi-bin/material/get_material'

API_UPLOAD

API_UPLOAD = 'https://api.weixin.qq.com/cgi-bin/material/add_material'

API_DELETE

API_DELETE = 'https://api.weixin.qq.com/cgi-bin/material/del_material'

API_STATS

API_STATS = 'https://api.weixin.qq.com/cgi-bin/material/get_materialcount'

API_LISTS

API_LISTS = 'https://api.weixin.qq.com/cgi-bin/material/batchget_material'

API_NEWS_UPLOAD

API_NEWS_UPLOAD = 'https://api.weixin.qq.com/cgi-bin/material/add_news'

API_NEWS_UPDATE

API_NEWS_UPDATE = 'https://api.weixin.qq.com/cgi-bin/material/update_news'

API_NEWS_IMAGE_UPLOAD

API_NEWS_IMAGE_UPLOAD = 'https://api.weixin.qq.com/cgi-bin/media/uploadimg'

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

uploadImage()

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

Upload image.

Parameters

string $path

Returns

\EasyWeChat\Support\Collection

uploadVoice()

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

Upload voice.

Parameters

string $path

Returns

\EasyWeChat\Support\Collection

uploadThumb()

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

Upload thumb.

Parameters

string $path

Returns

\EasyWeChat\Support\Collection

uploadVideo()

uploadVideo(string  $path, string  $title, string  $description) : \EasyWeChat\Support\Collection

Upload video.

Parameters

string $path
string $title
string $description

Returns

\EasyWeChat\Support\Collection

updateArticle()

updateArticle(string  $mediaId, array  $article, integer  $index) : \EasyWeChat\Support\Collection

Update article.

Parameters

string $mediaId
array $article
integer $index

Returns

\EasyWeChat\Support\Collection

uploadArticleImage()

uploadArticleImage(string  $path) : \EasyWeChat\Support\Collection

Upload image for article.

Parameters

string $path

Returns

\EasyWeChat\Support\Collection

get()

get(string  $mediaId) : mixed

Fetch material.

Parameters

string $mediaId

Returns

mixed

delete()

delete(string  $mediaId) : \EasyWeChat\Support\Collection

Delete material by media ID.

Parameters

string $mediaId

Returns

\EasyWeChat\Support\Collection

lists()

lists(string  $type, integer  $offset, integer  $count = 20) : array

List materials.

example:

{ "total_count": TOTAL_COUNT, "item_count": ITEM_COUNT, "item": [{ "media_id": MEDIA_ID, "name": NAME, "update_time": UPDATE_TIME }, // more... ] }

Parameters

string $type
integer $offset
integer $count

Returns

array

stats()

stats() : array

Get stats of materials.

Returns

array

getAPIByType()

getAPIByType(string  $type) : string

Get API by type.

Parameters

string $type

Returns

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

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

uploadMedia()

uploadMedia(string  $type, string  $path, array  $form = array()) : \EasyWeChat\Support\Collection

Upload material.

Parameters

string $type
string $path
array $form

Throws

\EasyWeChat\Core\Exceptions\InvalidArgumentException

Returns

\EasyWeChat\Support\Collection