作者: as123123 時間: 2014-2-26 16:28 標題: 有無c兄幫手整這個API
有無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
作者: 7h1r733n 時間: 2014-2-26 17:43
本帖最後由 7h1r733n 於 2014-2-26 17:48 編輯
回復 1# as123123
佢咪寫左usage囉...
USAGE: php upload.api.php [VIDEO TO UPLOAD] {SUB FILE-OPTIONAL}
呢個係shellscript黎.. 用command line run架.. 當然你可以轉做web版... 其實呢個只係一個好簡單用curl做http post o既example.....
