[其他] 有無c兄幫手整這個API

有無c兄幫手整這個API
我唔明點樣用  幫忙一下  
謝謝
  1. USAGE: php upload.api.php [VIDEO TO UPLOAD] {SUB FILE-OPTIONAL}
  2. <?php
  3. //OPTIONAL Registered Users - You can find your user token in API page.
  4. $user_token = "已經有";


  5. if(count($argv) < 2)
  6. die("Usage: php $argv[0] [VIDEO TO UPLOAD] {SUB FILE}\n");

  7. $file = $argv[1];
  8. if(!file_exists("$file"))
  9. die("ERROR: Can't find '$file'!\n");

  10. $path_parts = pathinfo($file);
  11. $ext = $path_parts['extension'];

  12. $allowed = array("flv", "avi", "rmvb", "mkv", 'mp4', 'wmv', 'mpeg', 'mpg');

  13. if (!in_array($ext,$allowed))
  14. die("ERROR: Video format not permitted. Formats allowed: .avi, .rmvb, .mkv, .flv, .mp4, .wmv, .mpeg, .mpg!\n");

  15. if(isset($argv[2]))
  16. {
  17. $sub_file = $argv[2];

  18. if(!file_exists("$sub_file"))
  19. die("ERROR: Can't find '$file'!\n");

  20. $path_parts = pathinfo($sub_file);
  21. $ext = $path_parts['extension'];

  22. $allowed = array("srt", "sub");

  23. if (!in_array($ext,$allowed))
  24. die("ERROR: Subtitle format not permitted. Formats allowed: .srt, .sub!\n");

  25. $post_fields['subfile'] = "@".$sub_file;
  26. }

  27. $post_fields['vfile'] = "@".$file;
  28. $post_fields['upload'] = "1";
  29. $post_fields ['token'] = 'sdfdsfFFs34676zabc';
  30. if(!empty($user_token))
  31. $post_fields['upload_hash'] = $user_token;

  32. $ch = curl_init();
  33. curl_setopt($ch, CURLOPT_URL,'http://convert.videomega.tv/uploadapi.php');
  34. curl_setopt($ch, CURLOPT_POST,1);
  35. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
  36. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  37. $result=curl_exec ($ch);
  38. curl_close ($ch);

  39. echo "$result\n";
  40. ?>
複製代碼
原本網
http://videomega.tv/?api

本帖最後由 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.....

TOP