\app\wechat\serviceMediaService

微信媒体文件管理 Class MediaService

Summary

Methods
Properties
Constants
getNewsById()
uploadImage()
uploadForeverMedia()
No public properties found
No constants found
getServerPath()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getNewsById()

getNewsById(integer  $id, array  $where = array()) : array

通过图文ID读取图文信息

Parameters

integer $id

本地图文ID

array $where

额外的查询条件

Throws

\think\db\exception\DataNotFoundException
\think\db\exception\ModelNotFoundException
\think\exception\DbException

Returns

array

uploadImage()

uploadImage(string  $local_url) : string

上传图片到微信服务器

Parameters

string $local_url

图文地址

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException
\think\Exception
\think\exception\PDOException

Returns

string

uploadForeverMedia()

uploadForeverMedia(string  $local_url, string  $type = 'image', array  $video_info = array()) : string|null

上传图片永久素材,返回素材media_id

Parameters

string $local_url

文件URL地址

string $type

文件类型

array $video_info

视频信息

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException
\think\Exception
\think\exception\PDOException

Returns

string|null

getServerPath()

getServerPath(string  $local) : string

文件位置处理

Parameters

string $local

Throws

\think\Exception
\think\exception\PDOException

Returns

string