DemoSubmitJob.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. require('../../../vendor/autoload.php');
  3. use Volc\Service\Imp\Models\Request\ImpSubmitJobRequest;
  4. use Volc\Service\Imp\Models\Response\ImpSubmitJobResponse;
  5. use Volc\Service\Imp\Models\Business\InputPath;
  6. use Volc\Service\Imp\Imp;
  7. // call below method if you don't set ak and sk in $HOME/.vcloud/config
  8. $client = Imp::getInstance();
  9. $client->setAccessKey("your ak");
  10. $client->setSecretKey("your sk");
  11. $request = new ImpSubmitJobRequest();
  12. $inputPath = new InputPath();
  13. $inputPath->setType("VOD");
  14. $inputPath->setVodSpaceName("your space name");
  15. $inputPath->setFileId("your file id");
  16. $request->setTemplateId("your template id");
  17. $request->setCallbackArgs("your callback args");
  18. $request->setEnableLowPriority("false"); // true 开启 false 不开启 闲时转码
  19. $request->setInputPath($inputPath);
  20. $response = new ImpSubmitJobResponse();
  21. try {
  22. $response = $client->SubmitJob($request);
  23. } catch (Exception $e) {
  24. echo $e, "\n";
  25. } catch (Throwable $e) {
  26. echo $e, "\n";
  27. }
  28. if ($response->getResponseMetadata()->getError() != null) {
  29. print_r($response->getResponseMetadata()->getError());
  30. }
  31. echo $response->serializeToJsonString();
  32. echo "\n";