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: 
rontom974
Visitor

Roku and php script Need HELP

Hello there.. im new to roku developing field
the channel i'm currently making is a video on demand type of app. i used videoplayer sdk
i hosted my categories.xml in to XML folder and named categories.php (local server)

categories.php code (categories.xml)

in categoryFeed.brs file i modified to this

conn.UrlPrefix = "file://pkg:/xml/categories.php"
conn.UrlCategoryFeed = conn.UrlPrefix + ""


categories.php looks like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Video On Demand" description="2015" sd_img="http://mywebsite.com/images/vod1155.png" hd_img="http://mywebsite.com/images/vod1155.png">
<categoryLeaf title="The Mind" description="" feed="http://webgurutech.com/roku/vod.php"/>
</category>
</categories>


and it worked perfectly alright. i can view the video contents in http://webgurutech.com/roku/vod.php


my problem is here
i hosted this vod.php file in xml folder where the categories.php in

and changed categories.php xml file line like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category title="Video On Demand" description="2015" sd_img="http://mywebsite.com/images/vod1155.png" hd_img="http://mywebsite.com/images/vod1155.png">
<categoryLeaf title="The Mind" description="" feed="file://pkg:/xml/vod.php"/>
</category>
</categories>


but the xml is not opening.

i checked in telnet and it shows this

Request Time: 1
Can't parse feed

This vod.php is feteching from a differnet xml which wont support in videoplayer
this is how the real xml looks like http://webgurutech.com/roku/cat.xml and i used some php scripts to make it like http://webgurutech.com/roku/vod.php this.

this is vod.php script

<?php

header('Content-Type:text/xml');


error_reporting(E_ALL);

$url = 'http://webgurutech.com/roku/cat.xml';


if (($response_xml_data = file_get_contents($url))===false){
echo "Error fetching XML\n";
} else {
libxml_use_internal_errors(true);
$data = simplexml_load_string($response_xml_data);
if (!$data) {
echo "Error loading XML\n";
foreach(libxml_get_errors() as $error) {
echo "\t", $error->message;
}
} else {
$vodXML = '<feed>
<endIndex>4</endIndex>
<resultLength>4</resultLength>'.PHP_EOL;
$vods = $data->code->vodList->vod;

for( $v=0; $v<count($vods);$v++) {
$vod = $vods[$v];
$vodItemXML .= '<item sdImg="' . $vod->attributes()->SDPosterUrl . '" hdImg="' . $vod->attributes()->HDPosterUrl . '">
<ContentType>'. $vod["ContentType"] .'</ContentType>
<title>' . $vod->attributes()->Title . '</title>
<contentType>Talk</contentType>
<contentQuality>SD</contentQuality>
<media>
<streamUrl>' . $vod->attributes()->urls . '</streamUrl>
<streamFormat>mp4</streamFormat>
<streamQuality>SD</streamQuality>
</media>
<synopsis>' . $vod->attributes()->ShortDescriptionLine1 . '</synopsis>
<streamformat>' . $vod->attributes()->Streamformat . '</streamformat>

</item>'.PHP_EOL;

}

$vodXML .= $vodItemXML . '</feed>';

echo $vodXML;
}

}


in browser it will open as xml file.
i want this vod.php file to be in local server /xml/ folder of videoplayer.zip (not in web server= websites)

does roku read php file. how can i make it work ? some one please help
im sorry for this long post 🙂
0 Kudos
5 REPLIES 5
rontom974
Visitor

Re: Roku and php script Need HELP

someone please help me. im waiting for someones help.. im new to brightscript. i only need to know does this file i created gonna work.
does roku reads php file.
thanks
0 Kudos
RokuMarkn
Visitor

Re: Roku and php script Need HELP

Your question isn't totally clear, but if I understand what you're asking the short answer is no, you can't execute a php script on the Roku. php is a server language. It almost always runs on a web server, not on a client.

Your php script is reading an xml file from a web server and reformatting it into a different xml file. It's possible to do this on the Roku but you'll have to write the code in Brightscript, not php. But frankly that would be a very convoluted way to do what you're trying to do. More straightforward would be to change the videoplayer code to handle the original xml file directly rather than trying to reformat it to match what the existing code does.

--Mark
0 Kudos
rontom974
Visitor

Re: Roku and php script Need HELP

is there any SDK or documentation to convert the xml like that. or how can i make it support this kind of xml file http://webgurutech.com/roku/cat.xml in videoplayer sdk.
0 Kudos
NewManLiving
Visitor

Re: Roku and php script Need HELP

Not sure what you are exactly doing but generally you download your xml using an roURLTransfer object. You can use ( preferable ) AsyncGetToString or if you need to save the file, AsyncGetToFile. Then use the built in xml components to parse the string or open the file and then parse the returned string :
l_str is the string returned from your transfer request
 l_xmlElement = CreateObject( "roXMLElement" )
l_xmlElement.Parse( l_str )
' Can use the functions or dot notation
' l_xmlList = l_xmlElement.GetNamedElements( "code" ).GetNamedElements( "vodList" ).GetChildElements()
' Using dot notation. This iterates through the vod elements and returns their attributes only put in a couple, but you get the idea
for each l_item in l_xmlElement.code.vodList.GetChildElements()
print l_item@id
print l_item@ContentType
print l_item@SDPosterUrl
print l_item@HDPosterUrl
' print ...
end for
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
0 Kudos
rontom974
Visitor

Re: Roku and php script Need HELP

does ajax call back work ?
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.