SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 2 Java
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/*
* ABOUT THIS PHP SAMPLE: This sample is part of the Elastic Transcoder Developer Guide topic at
2019-01-30 00:06:08 +00:00
* https://docs.aws.amazon.com/elastictranscoder/latest/developerguide/introduction.html
*
*/
2019-01-30 00:19:13 +00:00
// snippet-start:[elastictranscoder.php.create_job_status_notification_handler.import]
$tmp_path = '/tmp';
# Get raw notification data from the POST.
$data = file_get_contents('php://input');
$notification = json_decode($data, true);
if ($notification['Type'] == 'SubscriptionConfirmation') {
$subscription_file = "$tmp_path/subscribe_requests.txt";
# Dump subscription request into temp file.
file_put_contents($subscription_file, "$data\n", FILE_APPEND | LOCK_EX);
try {
# Automatically handle subscription confirmation requests.
echo 'url: ', $notification['SubscribeURL'];
$response = file_get_contents($notification['SubscribeURL']);
file_put_contents($subscription_file, "$response\n", FILE_APPEND | LOCK_EX);
} catch (Exception $e) {
file_put_contents(
$subscription_file,
"Error confirming subscription: {$e->getMessage()}\n",
FILE_APPEND | LOCK_EX
);
}
} elseif ($notification['Type'] == 'Notification') {
# Handle Elastic Transcoder notifications. In this example, we write them to
# $tmp_path/<job-id>.
$job_status = json_decode($notification['Message'], true);
file_put_contents(
"$tmp_path/{$job_status['jobId']}",
json_encode($job_status) . "\n",
FILE_APPEND | LOCK_EX
);
} else {
# Write unknown notifications out to disk.
file_put_contents("$tmp_path/unknown_notification.txt", "$data\n", FILE_APPEND | LOCK_EX);
}
2019-01-30 00:19:13 +00:00
// snippet-end:[elastictranscoder.php.create_job_status_notification_handler.import]