Installation guide

$signedUrlCannedPolicy = $cloudFront->getSignedUrl(array(
'url' => $streamHostUrl . '/' . $resourceKey,
'expires' => $expires,
'private_key' => '/path/to/your/cloudfront-private-key.pem',
'key_pair_id' => '<cloudfront key pair id>'
));
To use a custom policy, provide the policy key instead of expires.
$customPolicy = <<<POLICY
{
"Statement": [
{
"Resource": "{$resourceKey}",
"Condition": {
"IpAddress": {"AWS:SourceIp": "{$_SERVER['REMOTE_ADDR']}/32"},
"DateLessThan": {"AWS:EpochTime": {$expires}}
}
}
]
}
POLICY;
// Create a signed URL for the resource using a custom policy
$signedUrlCustomPolicy = $cloudFront->getSignedUrl(array(
'url' => $streamHostUrl . '/' . $resourceKey,
'policy' => $customPolicy,
));
The form of the signed URL is actually different depending on if the URL you are signing is using the "http" or "rtmp"
scheme. In the case of "http", the full, absolute URL is returned. For "rtmp", only the relative URL is returned for your
convenience, because some players require the host and path to be provided as separate parameters.
The following is an example of how you could use the signed URL to construct a web page displaying a video using
JWPlayer. The same type of technique would apply to other players like FlowPlayer, but will require different
client-side code.
<html>
<head>
<title>Amazon CloudFront Streaming Example</title>
<script type="text/javascript" src="https://example.com/jwplayer.js"></script>
</head>
<body>
<div id="video">The canned policy video will be here.</div>
<script type="text/javascript">
jwplayer('video').setup({
file: "<?= $streamHostUrl ?>/cfx/st/<?= $signedUrlCannedPolicy ?>",
width: "720",
height: "480"
});
</script>
</body>
</html>
This guide is incomplete
This guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of the
AWS PHP community, then helping to write documentation is a great place to start. Our guides are written in
Amazon CloudFront
54