Skip to content

Commit bedb148

Browse files
committed
drop php monitor pause
1 parent 109d1ef commit bedb148

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

RESTful service/monitor_pause.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
function monitor_update($account_access_key, $account_access_secret, $stream_id, $action_type){
4+
$request_url = 'https://api.acrcloud.com/v1/monitor-streams/' . $stream_id.'/' . $action_type;
5+
$http_method = 'PUT';
6+
$http_uri = '/v1/monitor-streams/' . $stream_id . '/' . $action_type;
7+
$timestamp = time();
8+
$signature_version = '1';
9+
10+
$string_to_sign = $http_method . "\n" .
11+
$http_uri ."\n" .
12+
$account_access_key . "\n" .
13+
$signature_version . "\n" .
14+
$timestamp;
15+
$signature = hash_hmac("sha1", $string_to_sign, $account_access_secret, true);
16+
$signature = base64_encode($signature);
17+
18+
$headerArray = array();
19+
$headers = array(
20+
'access-key' => $account_access_key,
21+
'timestamp' => $timestamp,
22+
'signature-version' => '1',
23+
'signature' => $signature
24+
);
25+
foreach( $headers as $n => $v ) {
26+
$headerArr[] = $n .':' . $v;
27+
}
28+
29+
$ch = curl_init();
30+
curl_setopt($ch, CURLOPT_URL, $request_url);
31+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
32+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
33+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr);
34+
$response = curl_exec($ch);
35+
var_dump($response);
36+
curl_close($ch);
37+
}
38+
39+
$account_access_key = '<account_access_key>';
40+
$account_access_secret = '<account_access_secret>';
41+
$stream_id = '<stream_id>';
42+
$action_type = 'pause'; // pause or restart
43+
44+
monitor_update($account_access_key, $account_access_secret, $stream_id, $action_type);
45+
?>

0 commit comments

Comments
 (0)