-
Notifications
You must be signed in to change notification settings - Fork 22
素材管理
Stoneworld edited this page Mar 7, 2016
·
1 revision
<?php
use Stoneworld\Wechat\Media;
$appId = 'wx8ac123b21f53d7m5';
$secret = '4ZDHIETJ6e0oENlEkRhYwzWPTrkLdXedKcPcRjCkgQkuHtQTJ12ZhWHESowrJqS9';
$media = new Media($appId, $secret);
-
$media->image($path);
//上传临时图片 -
$media->voice($path);
//上传临时声音 -
$media->video($path, $title, $description);
//上传临时视频 -
$media->file($path);
//上传临时文件 -
$media->forever($agentId)->image($path);
//上传永久图片 -
$media->forever($agentId)->voice($path);
//上传永久声音 -
$media->forever($agentId)->video($path);
//上传永久视频 -
$media->news($agentId, $articles);
//上传图文素材
$articles = [[
"title" => "TITLE",
"thumb_media_id" => "1R-dduRK217bpsmYgb_0kihAWC7Zo-WlZKIAGUEYrr4t1_2fKBL8CodLFk5vS3LoIzLcNJzwcYpGrHWMbFi8bCA",
"author" => "AUTHOR",
"content" =>"CONTENT",
"digest" => "DIGEST",
"show_cover_pic" => 0,
],
//若新增的是多图文素材,则此处应还有几段articles结构
];
-
$media->download($mediaId, $fileName);
//下载素材到本地 例如:$media->download($mediaId, __DIR__ . '/test.jpg');
; -
$media->forever($agentId)->download($mediaId, $filename);
//下载永久素材到本地,包含图文素材 因此$filename
可以为空; -
$media->forever($agentId)->delete($mediaId);
//删除永久素材 -
$media->updateNews($mediaId, array $articles, $agentId);
//更改图文素材 图文格式同上传图文素材 -
$media->lists($type, $offset, $count, $agentId);
//获取应用素材列表 -
$media->uploadImg($path);
//用于上传图片到企业号服务端,接口返回图片url