edit-icon download-icon

Add media

Last Updated: Mar 28, 2018

Add a video file to Media files:

  1. <?php
  2. include_once 'aliyun-openapi-php-sdk/aliyun-php-sdk-core/Config.php';
  3. use Mts\Request\V20140618 as Mts;
  4. # Step 1 set region
  5. $REGION = "cn-shenzhen";
  6. $OSS_REGION = "oss-cn-shenzhen";
  7. $mtsEndpoint = "mts." + REGION + ".aliyuncs.com";
  8. # Step 2.set accesskey & keySecret
  9. $accessKeyId = "";
  10. $accessKeySecret = "";
  11. # Create DefaultAcsClient instance and perform initialization
  12. $clientProfile = DefaultProfile::getProfile(
  13. $REGION, # Your Region ID
  14. $accessKeyId, # Your AccessKey ID
  15. $accessKeySecret # Your AccessKey Secret
  16. );
  17. $client = new DefaultAcsClient($clientProfile);
  18. $request = new Mts\AddMediaRequest();
  19. $request->setAcceptFormat('JSON');
  20. $request->setFileURL("http://mtb-sz-in.oss-cn-shenzhen.aliyuncs.com/media/r180-ABC.mp4");
  21. $request->setMediaWorkflowId("829bed0300994057a49e4f16de957e34");
  22. # Initiate request and handle returned result
  23. try {
  24. $response = $client->getAcsResponse($request);
  25. print 'RequestId is:' . $response->{'RequestId'} . "\n";;
  26. print "Response:".json_encode($response);
  27. } catch(ServerException $e) {
  28. print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";
  29. } catch(ClientException $e) {
  30. print 'Error: ' . $e->getErrorCode() . ' Message: ' . $e->getMessage() . "\n";
  31. }
  32. ?>
Thank you! We've received your feedback.