SyncVideo.php
901 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* 同步视频处理
*/
namespace Upyun\Api;
use GuzzleHttp\Client;
use Upyun\Config;
use Upyun\Signature;
class SyncVideo {
/**
* @var Config
*/
protected $config;
public function __construct(Config $config)
{
$this->config = $config;
}
public function process($params, $path) {
$client = new Client([
'timeout' => $this->config->timeout,
]);
$path = '/' . $this->config->serviceName . $path;
$method = 'POST';
$signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
$url = $this->config->getSyncVideoEndPoint() . $path;
$response = $client->request($method, $url, [
'headers' => $signedHeaders,
'json' => $params
]);
$body = $response->getBody()->getContents();
return json_decode($body, true);
}
}