-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupload.php
62 lines (49 loc) · 1.59 KB
/
upload.php
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
$AVideoSiteURL = "https://demo.avideo.com/";
$user = 'admin';
$pass = '123';
// File paths
$videoFilePath = 'video.mp4';
$imageFilePath = 'image.png';
// API endpoint URL
$apiUrl = "{$AVideoSiteURL}plugin/MobileManager/upload.php";
// cURL initialization
$ch = curl_init();
$imageData = base64_encode(file_get_contents($imageFilePath));
// Set the POST fields
$postFields = array(
'user' => $user, // required
'pass' => $pass, // required
'upl' => new CURLFile($videoFilePath), // required
'base64PNG' => $imageData, // optional
'title' => 'Upload test title '.date('Y-m-d H:i:s'), // optional
'description' => 'This is my video description. sent in '.date('Y-m-d H:i:s'), // optional
'categories_id' => 1, // optional
'can_share' => 1, // optional
'video_password' => '123456' // optional
);
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the cURL request
$response = curl_exec($ch);
// Check for errors
if ($response === false) {
echo 'Error: ' . curl_error($ch);
} else {
// Decode the JSON response
$jsonResponse = json_decode($response, true);
// Check if decoding was successful
if ($jsonResponse === null) {
echo 'Error: Failed to decode JSON response<hr>';
var_dump($postFields, $response);
} else {
header('Content-Type: application/json');
// Print the JSON response
echo $response;
}
}
// Close the cURL session
curl_close($ch);