Forum Discussion

matrixebiz's avatar
matrixebiz
Roku Guru
9 years ago

Code to have Roku wait for redirection link

Hello, there is some information I currently have the Roku read off a website which does work if I have it read the final destination website directly but what I need to do is send the Roku to a different link/site first that redirects it back to the final destination site which of course works in a web browser but is there some Brightscript code I can use that will allow the Roku to wait until the final destination site is landed on then read the information off that page? if you need more information let me know. Thank you

15 Replies

  • Hi Mark, the full url link is pumped through a PHP script re-direction so must be different that the regular HTTP re-direction 
    So what I need is the final destination page of text that you can see on the final landing page that I sent you in the PM which is "url" for the command below;
    IDArray = getStreamId(url)

    Let me know if you need more info.
  • "matrixebiz" wrote:
    Hi Mark, the full url link is pumped through a PHP script re-direction so must be different that the regular HTTP re-direction 

    A PHP redirection script should just use 30x headers to redirect, sounds like you are doing something else which is why Brightscript doesn't reach the final page.
    You are either going to need to post an example URL showing what actually happens, or chunks of the PHP code for people to actually see what you are on about.
  • In the latest PM you sent me, you indicated that you have two ways to access your URL, http://URL1, and http://URL2?http://URL1, where the latter is using the script at URL2 to redirect to URL1.  If you download each of those URLs yourself in a browser and look at the source, you will see that the first one just returns a plain JSON string, while the second one returns an HTML page, with some Javascript and HTML markup around the JSON string, and the JSON string is HTML-encoded, with & replaced by &, etc.  If you want to extract and use the JSON string from the second result, you'll have to either parse it out of the HTML yourself and decode it, or change the server so that URL2 just returns the raw result of URL1 without wrapping it in HTML.

    --Mark
  • Okay, I think I can decode it but how do I parse it out of the HTML? Thx
  • <sigh> you need to know how to write PHP and do the re-direct there. No, i do not know nor care about PHP but just this once will illustrate (because i can use google, cue http://stackoverflow.com/questions/768431 , http://stackoverflow.com/questions/8469767 😞
    <?php 
    header('Location: ' . $_SERVER['QUERY_STRING']);
    ?>

    Now, if you had the above script at URL2, then trying to load http://URL2?http://URL1 (per RokuMarkn's description) on Roku should "automaGically" return you the contents of URL1.

    The purpose of the whole exercise eludes me however. It smells of something that a spam, malware or copyright circumvention artist would do - so respectfully, i am out of here.