最近更新时间:2023.03.22 14:40:42
首次发布时间:2021.02.23 10:42:39
本文为您提供了服务端 PHP SDK 的媒体处理模块相关的 API 调用示例。主要包含:触发工作流、获取转码结果、获取工作流运行状态等。
使用前请前完成初始化,参考初始化。
接口请求参数和返回参数详见 OpenAPI:触发工作流。
<?php require('../../vendor/autoload.php'); $client = Volc\Service\Vod\Vod::getInstance(); $client->setAccessKey('your ak'); $client->setSecretKey('your sk'); $request = new Volc\Service\Vod\Models\Request\VodStartWorkflowRequest(); $request->setVid("your Vid"); $request->setTemplateId("your TemplateId"); $inputpath = new Volc\Service\Vod\Models\Business\WorkflowParams(); $inputpath->mergeFromJsonString('{"OverrideParams":{"TranscodeVideo":[{"TemplateId":["your templateId"]}]}}'); $request->setInput($inputpath); $request->setPriority(0); $request->setCallbackArgs("your CallbackArgs"); $request->setEnableLowPriority(false); $response = new Volc\Service\Vod\Models\Response\VodStartWorkflowResponse(); try { $response = $client->startWorkflow($request); } catch (Exception $e) { echo $e, "\n"; } catch (Throwable $e) { echo $e, "\n"; } if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) { echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n"; } else { echo $response->serializeToJsonString(), "\n"; }
接口请求参数和返回参数详见 OpenAPI:获取转码结果。
<?php require('../../vendor/autoload.php'); $client = Volc\Service\Vod\Vod::getInstance(); $client->setAccessKey('your ak'); $client->setSecretKey('your sk'); $request = new Volc\Service\Vod\Models\Request\VodRetrieveTranscodeResultRequest(); $request->setVid("your Vid"); $request->setResultType("your ResultType"); $response = new Volc\Service\Vod\Models\Response\VodRetrieveTranscodeResultResponse(); try { $response = $client->retrieveTranscodeResult($request); } catch (Exception $e) { echo $e, "\n"; } catch (Throwable $e) { echo $e, "\n"; } if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) { echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n"; } else { echo $response->serializeToJsonString(), "\n"; }
接口请求参数和返回参数详见 OpenAPI:获取工作流运行状态。
<?php require('../../vendor/autoload.php'); $client = Volc\Service\Vod\Vod::getInstance(); $client->setAccessKey('your ak'); $client->setSecretKey('your sk'); $request = new Volc\Service\Vod\Models\Request\VodGetWorkflowExecutionStatusRequest(); $request->setRunId("your RunId"); $response = new Volc\Service\Vod\Models\Response\VodGetWorkflowExecutionStatusResponse(); try { $response = $client->GetWorkflowExecution($request); } catch (Exception $e) { echo $e, "\n"; } catch (Throwable $e) { echo $e, "\n"; } if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) { echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n"; } else { echo $response->serializeToJsonString(), "\n"; }
接口请求参数和返回参数详见 OpenAPI:获取工作流执行结果。
<?php require('../../vendor/autoload.php'); $client = Volc\Service\Vod\Vod::getInstance(); $client->setAccessKey('your ak'); $client->setSecretKey('your sk'); $request = new Volc\Service\Vod\Models\Request\VodGetWorkflowResultRequest(); $request->setRunId("your RunId"); $response = new Volc\Service\Vod\Models\Response\VodGetWorkflowResultResponse(); try { $response = $client->GetWorkflowExecutionResult($request); } catch (Exception $e) { echo $e, "\n"; } catch (Throwable $e) { echo $e, "\n"; } if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) { echo $response->getResponseMetadata()->getError()->serializeToJsonString(), "\n"; } else { echo $response->serializeToJsonString(), "\n"; }