Obtain Token Example

The following code-snippet is an example in PHP on how to obtain a streaming token for a movie.

<?php
$baseurl = "http://dorcel.reflector.streaming.in2ip.nl/?video=";
$videofolder = "80605_HD/";
$videobasename = explode("_", $videofolder);
$videourl = $baseurl . $videofolder;

$username = "yourusername";
$password = "yourpassword";

// Create a stream for authentication.
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Authorization: Basic " . base64_encode("$username:$password")
  )
);
$context = stream_context_create($opts);
$token_url = $videourl . "video2.smil&service=token&play_offset=300&play_duration=60";

$token = trim(file_get_contents($token_url, false, $context));
?>