Media.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\wechat;
  12. use app\service\admin\wechat\WechatMediaService;
  13. use core\base\BaseAdminController;
  14. /**
  15. * 微信公众号素材管理
  16. */
  17. class Media extends BaseAdminController
  18. {
  19. public function lists()
  20. {
  21. $data = $this->request->params([
  22. ['type', ''],
  23. ]);
  24. return success((new WechatMediaService())->getMediaPage($data));
  25. }
  26. /**
  27. * 上传图片素材
  28. * @return \think\Response
  29. * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
  30. * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
  31. */
  32. public function image() {
  33. $data = $this->request->params([
  34. ['file', 'file'],
  35. ]);
  36. return success((new WechatMediaService())->addImageMedia($data));
  37. }
  38. /**
  39. * 上传视频素材
  40. * @return \think\Response
  41. * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
  42. * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
  43. */
  44. public function video() {
  45. $data = $this->request->params([
  46. ['file', 'file'],
  47. ]);
  48. return success((new WechatMediaService())->addVideoMedia($data));
  49. }
  50. /**
  51. * 同步草稿箱
  52. * @return \think\Response
  53. * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
  54. * @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
  55. */
  56. public function syncNews() {
  57. return success((new WechatMediaService())->syncNewsMedia());
  58. }
  59. }