Files
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

78 lines
2.0 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace crmeb\services\wechat\client\work;
use crmeb\services\wechat\client\BaseClient;
use EasyWeChat\Kernel\HttpClient\Response;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
/**
* 附件管理
* Class MediaClient
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
* @package crmeb\services\wechat\client\work
*/
class MediaClient extends BaseClient
{
/**
* @param string $type
* @param string $path
* @param array $form
* @return Response
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function upload(string $type, string $path, array $form = []): Response
{
$files = [
'media' => $path,
];
return $this->httpUpload('cgi-bin/media/upload', $files, $form, compact('type'));
}
/**
* 上传附件资源
* @param string $path
* @param string $mediaType
* @param string $attachmentType
* @return Response
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function uploadAttachment(string $path, string $mediaType, string $attachmentType): Response
{
$query = [
'media_type' => $mediaType,
'attachment_type' => $attachmentType,
];
return $this->httpUpload('cgi-bin/media/upload_attachment', ['media' => $path], $query);
}
/**
* 获取临时素材
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
* @param string $mediaId
* @return Response
* @throws TransportExceptionInterface
*/
public function get(string $mediaId): Response
{
return $this->getResources($mediaId, 'cgi-bin/media/get');
}
}