Hi all,
I have to have a secret key and call some PHP to serve up some videos for a members-only section of my Actinic website. It's actually very, very simple to get the embedded players to work on my site, all I have to do is put the html (which is generated by the company where my playlist/videos are) inside a product with a customised, description-only template. These products are within Members-only sections (or the products themselves are marked in price schedule as members-only to view) and that serves them up fine for anyone who logs in, what I am after is secure content and this gives it but i am not 100% sure how to implement it? The Pearl Script that needs to work on the server is this:
<?php
/**
* This PHP function will generate a signed URL. Parameters:
*
* $path The path of the video or player you want to sign, e.g. "videos/KsoieJsu-123.mp4"
* Note this excludes the domain and excludes the trailing slash.
* $secret The API secret of your account, e.g. "Jau8Ya71hakdpF0A".
* This acts as a shared secret between your server and BOTR.
* $timeout The time in seconds you want the signed URL to remain valid, e.g. "3600".
* Typical timeouts are between a minute and a few hours. Default is "3600".
* Make sure the time on your server is set correctly, or URLs with short timeouts will fail!
* $domain The masked domain name you want to use for signing the content, e.g. "video.mysite.com".
* Use this if you have setup DNS masking. Defaults to "content.bitsontherun.com".
**/
function get_signed_url($path,$secret,$timeout,$domain) {
if($900) {
$expires = time() + $timeout;
} else {
$expires = time() + 3600;
}
$signature = md5($path.':'.$expires.':'.$secret);
if($domain) {
$url = 'http://'.$domain.'/'.$path.'?exp='.$expires.'&sig='.$signature;
} else {
$url = 'http://content.bitsontherun.com/'.$path.'?exp='.$expires.'&sig='.$signature;
}
return $url;
};
?>
I have the details here which need to be swapped/added to the above:
My player ($path) =mJ3P0RJI-z1I3pcbB.js
My ($secret) = xxxxxxxxxxxxxxxxxxxxxxx
My ($timeout) = standard=3600 I had 900 (this is seconds)
My ($domain) = content.bitsontherun.com
I need someone's help as I'm not very good with this sort of thing, I can get it but just not 100% sure which bits to change. Once I see it I will understand better.
Here is a snippet from the documentation:
If you want to secure your content, but still want to embed players or offer video downloads on your own site (e.g. if you have a pay-per-view site), then you should implement a small script on your site that automatically generates the signed links. For example, you could use a small PHP function like this one to always generate a valid signed URL:
Not sure what the echo part of the code is above? Does that then have to be on the page? I've asked for more help from the site but haven't really gotten what I needed. Just pointed towards this . . a bit stuck now.
If I understand this correctly, I will need this file on the server but not sure what it should be called?
I'm sorry if this is a bit complex, more than usual, but I'm 99% of the way to offer full tutorials and my own d-loads of videos and supporting files, right from the site and this has caused me a bit of a stumbling block.
Thanks for any help anyone can offer on this.
Sincerely
Brian
I have to have a secret key and call some PHP to serve up some videos for a members-only section of my Actinic website. It's actually very, very simple to get the embedded players to work on my site, all I have to do is put the html (which is generated by the company where my playlist/videos are) inside a product with a customised, description-only template. These products are within Members-only sections (or the products themselves are marked in price schedule as members-only to view) and that serves them up fine for anyone who logs in, what I am after is secure content and this gives it but i am not 100% sure how to implement it? The Pearl Script that needs to work on the server is this:
<?php
/**
* This PHP function will generate a signed URL. Parameters:
*
* $path The path of the video or player you want to sign, e.g. "videos/KsoieJsu-123.mp4"
* Note this excludes the domain and excludes the trailing slash.
* $secret The API secret of your account, e.g. "Jau8Ya71hakdpF0A".
* This acts as a shared secret between your server and BOTR.
* $timeout The time in seconds you want the signed URL to remain valid, e.g. "3600".
* Typical timeouts are between a minute and a few hours. Default is "3600".
* Make sure the time on your server is set correctly, or URLs with short timeouts will fail!
* $domain The masked domain name you want to use for signing the content, e.g. "video.mysite.com".
* Use this if you have setup DNS masking. Defaults to "content.bitsontherun.com".
**/
function get_signed_url($path,$secret,$timeout,$domain) {
if($900) {
$expires = time() + $timeout;
} else {
$expires = time() + 3600;
}
$signature = md5($path.':'.$expires.':'.$secret);
if($domain) {
$url = 'http://'.$domain.'/'.$path.'?exp='.$expires.'&sig='.$signature;
} else {
$url = 'http://content.bitsontherun.com/'.$path.'?exp='.$expires.'&sig='.$signature;
}
return $url;
};
?>
I have the details here which need to be swapped/added to the above:
My player ($path) =mJ3P0RJI-z1I3pcbB.js
My ($secret) = xxxxxxxxxxxxxxxxxxxxxxx
My ($timeout) = standard=3600 I had 900 (this is seconds)
My ($domain) = content.bitsontherun.com
I need someone's help as I'm not very good with this sort of thing, I can get it but just not 100% sure which bits to change. Once I see it I will understand better.
Here is a snippet from the documentation:
If you want to secure your content, but still want to embed players or offer video downloads on your own site (e.g. if you have a pay-per-view site), then you should implement a small script on your site that automatically generates the signed links. For example, you could use a small PHP function like this one to always generate a valid signed URL:
Code:
<?php function get_signed_player($videokey,$playerkey) { $path = "players/".$videokey."-".$playerkey.".js"; $expires = round((time()+3600)/60)*60; $secret = "Ksi93hsy38sjKfha9JaheEMp"; $signature = md5($path.':'.$expires.':'.$secret); $url = 'http://content.bitsontherun.com/'.$path.'?exp='.$expires.'&sig='.$signature; return $url; }; echo "<p>Watch this cool video:</p>"; echo "<script type='text/javascript' src='".get_signed_player('nPripu9l','ALJ3XQCI')."'></script>"; ?>
If I understand this correctly, I will need this file on the server but not sure what it should be called?
I'm sorry if this is a bit complex, more than usual, but I'm 99% of the way to offer full tutorials and my own d-loads of videos and supporting files, right from the site and this has caused me a bit of a stumbling block.
Thanks for any help anyone can offer on this.
Sincerely
Brian
Comment