有無c兄幫手整這個API
我唔明點樣用 幫忙一下
謝謝- USAGE: php upload.api.php [VIDEO TO UPLOAD] {SUB FILE-OPTIONAL}
- <?php
- //OPTIONAL Registered Users - You can find your user token in API page.
- $user_token = "已經有";
- if(count($argv) < 2)
- die("Usage: php $argv[0] [VIDEO TO UPLOAD] {SUB FILE}\n");
- $file = $argv[1];
- if(!file_exists("$file"))
- die("ERROR: Can't find '$file'!\n");
- $path_parts = pathinfo($file);
- $ext = $path_parts['extension'];
- $allowed = array("flv", "avi", "rmvb", "mkv", 'mp4', 'wmv', 'mpeg', 'mpg');
- if (!in_array($ext,$allowed))
- die("ERROR: Video format not permitted. Formats allowed: .avi, .rmvb, .mkv, .flv, .mp4, .wmv, .mpeg, .mpg!\n");
- if(isset($argv[2]))
- {
- $sub_file = $argv[2];
- if(!file_exists("$sub_file"))
- die("ERROR: Can't find '$file'!\n");
- $path_parts = pathinfo($sub_file);
- $ext = $path_parts['extension'];
- $allowed = array("srt", "sub");
- if (!in_array($ext,$allowed))
- die("ERROR: Subtitle format not permitted. Formats allowed: .srt, .sub!\n");
- $post_fields['subfile'] = "@".$sub_file;
- }
- $post_fields['vfile'] = "@".$file;
- $post_fields['upload'] = "1";
- $post_fields ['token'] = 'sdfdsfFFs34676zabc';
- if(!empty($user_token))
- $post_fields['upload_hash'] = $user_token;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,'http://convert.videomega.tv/uploadapi.php');
- curl_setopt($ch, CURLOPT_POST,1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $result=curl_exec ($ch);
- curl_close ($ch);
- echo "$result\n";
- ?>
複製代碼 原本網
http://videomega.tv/?api |