I need help with the vidguard api

Faris

New Member
4
2023
1
170
Hello everybody. I have been using VidGuard for a short time and I need your help. Does anyone know how to upload a file to their server in php?
thanks in advance
 
8 comments
cool, could you give me the code please ?
PHP:
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://video.server.com/v1/upload?token=8ZI27C4Nx7DSWo-7wtMIFA');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$post = array(
    'file' => '@' .realpath('/path/to/video.mp4'),
    'key' => '{APIKey}',
    'folder' => '{FolderID}'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
 
thanks for your help but it still doesn't work. maybe I did some mistake in my code
Post automatically merged:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,linkwith my key);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$post = array(
'file' => '@' .realpath('content/' . $lastid . '.mp4'),
'key' => '**',
'folder' => '11387'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
 
thanks for your help but it still doesn't work. maybe I did some mistake in my code
Post automatically merged:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,linkwith my key);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$post = array(
'file' => '@' .realpath('content/' . $lastid . '.mp4'),
'key' => '**',
'folder' => '11387'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
what error you get? can capture here..?
 
Here you, I made this for you.


PHP:
<?php

$apikey = "APIKEY";
$filename = "/var/www/html/vidguard/test.mp4";

$key = file_get_contents("https://api.vidguard.to/v1/upload/server?key=$apikey");
$json = json_decode($key, true);
if ($json['msg'] !="Done")
    die("MSG:".$json['msg']);
$ch = curl_init();

if (function_exists('curl_file_create')) {
  $cfile = curl_file_create($filename);
} else {
  $cfile = '@' . realpath($filename);
}

$post = array('key' => $apikey, 'file' => $cfile);
curl_setopt($ch, CURLOPT_URL,$json['result']['url']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);

$cson = json_decode($result, true);

// print_r($cson);

if ($cson['status'] !=200)
    die("MSG:".$cson['msg']);

echo "URL:" . $cson['result']['URL'];
 
Here you, I made this for you.


PHP:
<?php

$apikey = "APIKEY";
$filename = "/var/www/html/vidguard/test.mp4";

$key = file_get_contents("https://api.vidguard.to/v1/upload/server?key=$apikey");
$json = json_decode($key, true);
if ($json['msg'] !="Done")
    die("MSG:".$json['msg']);
$ch = curl_init();

if (function_exists('curl_file_create')) {
  $cfile = curl_file_create($filename);
} else {
  $cfile = '@' . realpath($filename);
}

$post = array('key' => $apikey, 'file' => $cfile);
curl_setopt($ch, CURLOPT_URL,$json['result']['url']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);

$cson = json_decode($result, true);

// print_r($cson);

if ($cson['status'] !=200)
    die("MSG:".$cson['msg']);

echo "URL:" . $cson['result']['URL'];
perfect
 
Back
Top