$region, 'default_caching_config' => '/tmp']); // This function will create an Elastic Transcoder job using the supplied elastic // transcoder client, pipeline id, input key and output key prefix. Output key // is automatically set to SHA256(UTF8()). function create_elastic_transcoder_job($transcoder_client, $pipeline_id, $input_key, $preset_id, $output_key_prefix) { // Set up the job input using the provided input key. $input = ['Key' => $input_key]; // Set up the job output using the provided input key to generate an output key. $outputs = [['Key' => hash("sha256", utf8_encode($input_key)), 'PresetId' => $preset_id]]; // Create the job. $create_job_request = [ 'PipelineId' => $pipeline_id, 'Input' => $input, 'Outputs' => $outputs, 'OutputKeyPrefix' => $output_key_prefix ]; $create_job_result = $transcoder_client->createJob($create_job_request)->toArray(); return $job = $create_job_result["Job"]; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { // If the request method is POST, create a job using the posted data and save // the job information into the status file. try { $job = create_elastic_transcoder_job( $transcoder_client, $_POST['pipelineid'], $_POST['inputkey'], $preset_id, $output_key_prefix ); $status_file = "$tmp_path/{$job['Id']}"; file_put_contents($status_file, json_encode($job, true) . "\n", FILE_APPEND | LOCK_EX); header("Location: JobStatusNotificationsSample.php?Id={$job['Id']}"); } catch (Exception $e) { echo "Exception occurred: {$e->getMessage()}\n"; } } elseif ($_SERVER['REQUEST_METHOD'] && array_key_exists('Id', $_GET)) { // If the request method is GET and 'Id' has been specified, then set the status file. $status_file = "$tmp_path/{$_GET['Id']}"; if (is_file($status_file)) { echo '
';
        echo file_get_contents($status_file);
        echo '
'; } else { echo "No job status file found."; } } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') { // If the request method is GET and no 'Id' is specified, return the HTML form // which will allow the user to create an elastic transcoder job. echo "Create an Elastic Transcoder job and consume job status using notifications.
"; echo "
Pipeline Id: ("; echo "Create an Elastic Transcoder Pipeline)
Input key:
"; echo "
"; } // snippet-end:[elastictranscoder.php.create_job_status_notification.import]