Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
railfan
Channel Surfer

PHP Script and XML

Hi everyone I am new to this so I am looking for some help. I am not sure if this is something I should be doing in brightscript or in side the xml for my list of channels. I have everything working but I am adding secure streaming to our wowza server. I need to figure out how to get this working on my Roku box.

<?php
$today = gmdate("n/j/Y g:i:s A");
$ip = $_SERVER['REMOTE_ADDR'];
$key = "MYKEYWORKS";
$validminutes = 20;
$str2hash = $ip . $key . $today . $validminutes;
$md5raw = md5($str2hash, true);
$base64hash = base64_encode($md5raw);
$urlsignature = "server_time=" . $today ."&hash_value=" . $base64hash. "&validminutes=$validminutes";
$base64urlsignature = base64_encode($urlsignature);
?>


I need to add this string to my URL for access the stream inside my XML file ?wmsAuthSign=<?php echo $base64urlsignature?> So I am looking for help to get it working thanks for everyone's help.

Here is a section of m XML file

<item sdImg="http://www.railstream.biz/roku/images/Grand_Island.png" hdImg="http://www.railstream.biz/roku/images/Grand_Island.png">
<title>Grand Island, NE Camera</title>
<contentId>10001</contentId>
<contentType>Live Trains</contentType>
<contentQuality>SD</contentQuality>
<streamFormat>hls</streamFormat>
<media>
<streamQuality>SD</streamQuality>
<streamBitrate>1000</streamBitrate>
<streamUrl>http://streamingserverURL:1935/live/STREAMCHANNEL.sdp/playlist.m3u8</streamUrl>
</media>
<synopsis>RailStream live camera from Grand Island, NE looking at the Union Pacific Main line just west of the BNSF Flyover.</synopsis>
<genres>RailCam</genres>
</item>

Mike
0 Kudos
3 REPLIES 3
joetesta
Roku Guru

Re: PHP Script and XML

What you can do is to build a script on your server which returns the path with the string attached. So in your XML instead of

<streamUrl>http://streamingserverURL:1935/live/STREAMCHANNEL.sdp/playlist.m3u8</streamUrl>


you would have something like

<streamUrl>http://myserver.com/playlistX.mp4</streamUrl>


Then when they call playlistX.mp4 you process that with php and send their browser to the location
http://streamingserverURL:1935/live/STREAMCHANNEL.sdp/playlist.m3u8 + your encrypted string
aspiring
0 Kudos
railfan
Channel Surfer

Re: PHP Script and XML

That sounds like a great idea would this be a script I would have run every "X" minutes? Could you share how to do this I think a linux job that runs the php script would be what is needed but it would also create the file correct?
0 Kudos
RokuJoel
Binge Watcher

Re: PHP Script and XML

There's no reason why you couldn't do this on the Roku device itself. See the Flickr example for some hash generation code that might be helpful.

- Joel
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.