新增阿里云oss上传文件
This commit is contained in:
@@ -79,4 +79,24 @@ class Oss
|
||||
{
|
||||
return str_replace('+00:00', '.000Z', gmdate('c', $time));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传
|
||||
* @param string $filename 图片名称
|
||||
* @param mixed $content 内容 字符串或文件流
|
||||
* @return string
|
||||
*/
|
||||
public function putObject(string $filename, mixed $content): string
|
||||
{
|
||||
try {
|
||||
$ossClient = $this->createClient();
|
||||
|
||||
$object = "applet/doctor/card/".$filename;
|
||||
$ossClient->putObject($this->config['bucket'], $object, $content);
|
||||
|
||||
return $object;
|
||||
}catch(\Exception $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,4 +217,44 @@ class Wechat
|
||||
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取分享二维码
|
||||
|
||||
/**
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws DecodingExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
*/
|
||||
public function getUnlimitedQRCode(array $options){
|
||||
try {
|
||||
$this->createApp($this->config['app_id'], $this->config['secret']);
|
||||
|
||||
$client = $this->createClient($this->config['app_id'], $this->config['secret']);
|
||||
|
||||
$response = $client->postJson('wxa/getwxacodeunlimit', $options);
|
||||
|
||||
if ($response->isFailed()) {
|
||||
// 出错了,处理异常
|
||||
$result = $response->toArray();
|
||||
if(empty($result)){
|
||||
// 返回值为空
|
||||
return [];
|
||||
}
|
||||
if (isset($result['errcode'])){
|
||||
throw new BusinessException();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
return $response->getContent(true);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user