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: 
newchannel
Roku Guru

Re: setadurl question

This is a link to an ad rotation php script I located.

http://www.cypherhackz.net/archives/200 ... e-banners/

I made a file called adverts and inside of it I have rotateads.php . I uploaded this to my server.

On posterscreen.brs I have added

screen.SetAdURL("http://myserver.net/adverts/rotateads.php", "http://www.myserver.net/adverts/rotateads.php")

On the webpage link it has:

To include the rotateads.php in your theme file, you need to call this function. I assume you have uploaded the file in your root folder.
<?php include(“/home/yourname/public_html/rotateads.php”); ?>

I have not added an "include" so do I put this inside of the adverts folder as a file? Do I make a folder for it? Do I need it?

My ads show up on posterscreen if I don't use the php script and just use the links to my images. But I need them to rotate so therefore need a php script. What is making the display ads disappear using this script? I have left off the include because I don't know where to place it so perhaps I do need it.

Any input appreciated from the forum.

Thank you.
http://www.victoryNOWfilmsandtv.com
0 Kudos
belltown
Roku Guru

Re: setadurl question

The easiest thing to do is just place the file, rotateads.php, in your server's top-level directory and call it as follows:

screen.SetAdURL("http://myserver.net/rotateads.php", "http://www.myserver.net/rotateads.php")


Then you won't have to worry about creating directories and setting the correct permissions, etc.

Once you have the file in your server's top level directory, try testing whether you can access it from a web browser; type http://www.myserver.net/rotateads.php into your browser's address field.

Check your server logs to make sure you don't have any compile errors or access errors for this script.

The include statement you mentioned is unnecessary in this context. You only need it if you are calling the code from another php script. In this case you are accessing the file from a web server not from another script so you need to make sure the web server is running and has access to the script then use the correct url to access it.
0 Kudos
newchannel
Roku Guru

Re: setadurl question

Apparently I don't have the file structured properly or the url.

On the server there is a file that reads public_html: do I put the php file just beneath this?

I typed into the browser but is says :


Parse error: syntax error, unexpected ':' in /home/xxxxxxxxxxx/public_html/rotateads.php on line 3

Back to the drawing board for me.

Thank you.
http://www.victoryNOWfilmsandtv.com
0 Kudos
belltown
Roku Guru

Re: setadurl question

Yes, the file goes in the public_html directory.

If you post your code here (within 'Code' tags for readability) we might be able to tell you what is causing the error.
0 Kudos
newchannel
Roku Guru

Re: setadurl question

Hi,

Here is the php file:

<?php
$bannerCounter = 1;
$bannerCode[$bannerCounter] = ‘http://www.xxxxxx.net/xxx/images/xxxxxxx540x60.jpg‘;
$bannerCounter++;
$bannerCode[$bannerCounter] = ‘http://www.xxxxxxx.net/xxx/images/xxxxxx540x60.jpg‘;
$bannerCounter++;
$bannerAdTotals = $bannerCounter – 1;
if($bannerAdTotals>1)
{
mt_srand((double)microtime() * 1234567);
$bannerPicked = mt_rand(1, $bannerAdTotals);
}
else
{
$bannerPicked = 1;
}
$bannerAd = $bannerCode[$bannerPicked];
echo $bannerAd;
?>





Thank you
http://www.victoryNOWfilmsandtv.com
0 Kudos
belltown
Roku Guru

Re: setadurl question

Try this:


<?php
$bannerCounter = 1;
$bannerCode[$bannerCounter] = 'http://www.xxxxxx.net/xxx/images/xxxxxxx540x60.jpg';
$bannerCounter++;
$bannerCode[$bannerCounter] = 'http://www.xxxxxxx.net/xxx/images/xxxxxx540x60.jpg';
$bannerCounter++;
$bannerAdTotals = $bannerCounter - 1;

if($bannerAdTotals>1)
{
mt_srand((double)microtime() * 1234567);
$bannerPicked = mt_rand(1, $bannerAdTotals);
}
else
{
$bannerPicked = 1;
}
$bannerAd = $bannerCode[$bannerPicked];
echo $bannerAd;
?>


It didn't like the (`) characters you were using to delimit your strings. You should be using (') instead.
0 Kudos
newchannel
Roku Guru

Re: setadurl question

Thanks belltown.

I copied the code. Should it be a "file" or a "file" inside of a "folder" I originally had it in a folder like /adverts/rotateads.php but then tried it as just the file alone on the server. Which way is best?

I typed into a browser but stills gives me that syntax error I listed above. Maybe it's the server? It's a temporary server for websites where I have my info while building the channel but they say on their site that it accepts php.

A little bit ago I saw that there is another php file on the server under the public_html. The server company has some written info that says to "delete the default.php file and upload your website." I have not deleted it yet. Curious if that's the problem yet that should not cause a "syntax error". I'm not quick to delete files if I am not sure I should. Coding is new to me but doing my best to learn.

Still have to make progress on the pre-roll ads. That is still foreign to me.

Thank you for the help so far.
http://www.victoryNOWfilmsandtv.com
0 Kudos
belltown
Roku Guru

Re: setadurl question

The easiest thing to do is to put the rotateads.php (the file), in the public_html directory. It sounds like you had it in the right place before otherwise you wouldn't have been able to run it and wouldn't have got the syntax error.

If you're still getting the same error then either you haven't uploaded the edited file to your server (maybe you didn't save the edits or maybe you uploaded it to a different place other than public_html/rotateads.php), or maybe your browser is returning the old version from its cache (try clicking the browser's 'refresh' button), or maybe your server is returning an old version of the file from its cache -- try running the file from your browser but specify a random parameter to ensure the url is unique from the one you used before, e.g: http://myserver.net/rotateads.php?1234567

The default.php file that you mentioned should have nothing to do with this problem. It's most likely the file that runs when you specify the url for your web site without specifying a filename, e.g. http://myserver.net/ At some point you should put something in there other than the default otherwise your web hosting provider might think you don't have a web site up and running and may delete your account.
0 Kudos
newchannel
Roku Guru

Re: setadurl question

Hi belltown,

I did a re-do. Now what happens is no syntax error. Thank you.

But instead of getting the ad image within my browser, it gives me the actually the typed words: "http://xxxxx.net/xxx.xxxxxxx.jpg

instead of the image graphic.
http://www.victoryNOWfilmsandtv.com
0 Kudos
newchannel
Roku Guru

Re: setadurl question

Should the images for the ads be inside of the adverts folder? or can they be in my images folder with the rest of the images for the channel?
http://www.victoryNOWfilmsandtv.com
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.