Files
huangjingfen/pro_v3.5.1/crmeb/services/wechat/client/BaseClient.php
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

73 lines
1.8 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace crmeb\services\wechat\client;
use EasyWeChat\Kernel\Form\File;
use EasyWeChat\Kernel\Form\Form;
use EasyWeChat\Kernel\HttpClient\Response;
use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
/**
* 基础接口请求
* Class BaseClient
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/18
* @package crmeb\services\wechat\client
*/
abstract class BaseClient
{
/**
* UserClient constructor.
* @param AccessTokenAwareClient $api
*/
public function __construct(protected AccessTokenAwareClient $api)
{
}
/**
* 上传文件
* @param string $url
* @param array $files
* @param array $form
* @param array $query
* @return Response
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function httpUpload(string $url, array $files = [], array $form = [], array $query = [])
{
$form['media'] = File::fromPath($files['media']);
$options = Form::create($form)->toArray();
return $this->api->request(
'POST',
$url.'?'.http_build_query($query),
$options
);
}
/**
* @param string $mediaId
* @param string $uri
* @return Response
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
protected function getResources(string $mediaId, string $uri)
{
return $this->api->request('GET', $uri, [
'query' => [
'media_id' => $mediaId,
],
]);
}
}