meedu版本:v3.7.4
alibabacloud/client扩展版本:v1.5.30
环境:PHP7.2
在测试的时候,阿里云视频点播的节点选择的是北京(cn-beijing
),配置完成后,上传点播视频时报错
[2021-04-17 08:37:59] local.ERROR: exception {"message":"InvalidStorage.NotFound: The storageLocation does not exist. RequestId: ****-9E1F-4367-821D-****GET \"http://vod.cn-shanghai.aliyuncs.com\" 403","code":403,"line":343,"params":{"title":"****.mp4","filename":"****.mp4"},"url":"http://*****/backend/api/v1/video/token/aliyun/create","method":"POST","ip":["******"]} {"request_id":"78RibM*****"}
经过查询阿里云官方文档,在调用 CreateUploadVideo
方法时,需要设置 host(uri)
属性,具体实现如下:
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
// Download:https://github.com/aliyun/openapi-sdk-php
// Usage:https://github.com/aliyun/openapi-sdk-php/blob/master/README.md
AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')
->regionId('cn-beijing')
->asDefaultClient();
try {
$result = AlibabaCloud::rpc()
->product('vod')
// ->scheme('https') // https | http
->version('2017-03-21')
->action('CreateUploadVideo')
->method('POST')
->host('vod.cn-beijing.aliyuncs.com')
->options([
'query' => [
'Title' => "***.mp4",
'FileName' => "***.mp4",
],
])
->request();
print_r($result->toArray());
} catch (ClientException $e) {
echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
echo $e->getErrorMessage() . PHP_EOL;
}
经过整体排查,其他调用vod接口部分也存在相关问题,一并添加设置host方法即可。
建议增加配置项增加设置host
属性的灵活性。