# does anybody have the code for linking roku device to websit

**URL:** <https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599>\
**Category:** Archived\
**Tags:** roku-developer-program\
**Created:** [January 30, 2012, 6:48am UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599 "2012-01-30T06:48:05Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Biju](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@Biju](https://forum.developer.roku.com/u/Biju)\
**Post date:** [January 30, 2012, 6:48am UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/1 "2012-01-30T06:48:05Z")

</div>

does anybody have the code for linking roku device to website for restricting user to view my private channel

---

<div class="post-metadata">

**Author:** ![joetesta](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@joetesta](https://forum.developer.roku.com/u/joetesta)\
**Post date:** [January 30, 2012, 11:26pm UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/2 "2012-01-30T23:26:41Z")

</div>

yes in the example applications that come with the SDK, look for the one called ‘register’ and merge it into your channel.

---

<div class="post-metadata">

**Author:** ![Biju](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@Biju](https://forum.developer.roku.com/u/Biju)\
**Post date:** [January 31, 2012, 5:52am UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/3 "2012-01-31T05:52:54Z")

</div>

> “joetesta” wrote:  
> yes in the example applications that come with the SDK, look for the one called ‘register’ and merge it into your channel.  
> How to merge it into my channel im? do you have the sample code for it?

---

<div class="post-metadata">

**Author:** ![joetesta](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@joetesta](https://forum.developer.roku.com/u/joetesta)\
**Post date:** [January 31, 2012, 5:57pm UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/4 "2012-01-31T17:57:55Z")

</div>

> “Biju” wrote:
> 
> > “joetesta” wrote:  
> > yes in the example applications that come with the SDK, look for the one called ‘register’ and merge it into your channel.  
> > How to merge it into my channel im? do you have the sample code for it?

the sample code is in the example application. for your custom app you probably have to figure it out or hire someone who can do it.

---

<div class="post-metadata">

**Author:** ![destruk](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@destruk](https://forum.developer.roku.com/u/destruk)\
**Post date:** [January 31, 2012, 7:25pm UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/5 "2012-01-31T19:25:38Z")

</div>

Or you could join the roku Premium Developer Program, where roku does all required linking and billing for you without you needing to have it in your app. Their cost is 30% of whatever you charge - last time I checked.

---

<div class="post-metadata">

**Author:** ![RokuJoel](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@RokuJoel](https://forum.developer.roku.com/u/RokuJoel)\
**Post date:** [January 31, 2012, 9:49pm UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/6 "2012-01-31T21:49:09Z")

</div>

Biju, here is a little thing I whipped up this morning which might solve your short-term private channel linking issue. I haven’t tested it, but it should work:

On your website, you create a text file of all the serial numbers, each on its own line.  
on the roku, In the very top of your channel, in sub main(), put in the following:

sub main()

```auto

    xfer=createobject("rourltransfer")
    xfer.seturl("http://mywebserver.com/serialnumbers.txt") 'the url and path to your file
    list=xfer.gettostring().tokenize(chr(10))
    di=createobject("rodeviceinfo")
    myserial=di.getdeviceuniqueID()
    ?myserial
    linked=false
    for each number in list
        if number.left(number.instr(chr(13)))=myserial or number=myserial then 
            linked=true
        end if
    end for
    if linked=false then 
        dialog=createobject("roonelinedialog")
        dialog.settitle("Serial number: "+myserial)
        ?"my SN=";myserial
        dialog.show()
        sleep(20000)
        dialog.close()
        return
    end if

```

end sub

Note that this has only been tested with a text file created by windows Notepad.

So essentially, if someone launches the app and their serial is not in your text file, it will display their serial number for 20 seconds and exit, otherwise, it should continue on to allow them access to your content.

---

<div class="post-metadata">

**Author:** ![Biju](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@Biju](https://forum.developer.roku.com/u/Biju)\
**Post date:** [February 1, 2012, 5:29am UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/7 "2012-02-01T05:29:16Z")

</div>

> “RokuJoel” wrote:  
> Biju, here is a little thing I whipped up this morning which might solve your short-term private channel linking issue. I haven’t tested it, but it should work:
> 
> On your website, you create a text file of all the serial numbers, each on its own line.  
> on the roku, In the very top of your channel, in sub main(), put in the following:
> 
> sub main()
> 
> ```auto
> 
> xfer=createobject("rourltransfer")
> xfer.seturl("http://mywebserver.com/serialnumbers.txt") 'the url and path to your file
> list=xfer.gettostring().tokenize(chr(10))
> di=createobject("rodeviceinfo")
> myserial=di.getdeviceuniqueID()
> ?myserial
> linked=false
> for each number in list
> if number.left(number.instr(chr(13)))=myserial or number=myserial then 
> linked=true
> end if
> end for
> if linked=false then 
> dialog=createobject("roonelinedialog")
> dialog.settitle("Serial number: "+myserial)
> ?"my SN=";myserial
> dialog.show()
> sleep(20000)
> dialog.close()
> return
> end if
> 
> ```
> 
> end sub
> 
> Note that this has only been tested with a text file created by windows Notepad.
> 
> So essentially, if someone launches the app and their serial is not in your text file, it will display their serial number for 20 seconds and exit, otherwise, it should continue on to allow them access to your content.  
> Thank you joel, but i didnt understand in which file on the roku i have to put these codes. is it in appmain.brs or somewhere else?

---

<div class="post-metadata">

**Author:** ![RokuJoel](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@RokuJoel](https://forum.developer.roku.com/u/RokuJoel)\
**Post date:** [February 1, 2012, 5:44pm UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/8 "2012-02-01T17:44:52Z")

</div>

Depends on which sample application you based your project on. If it is the videoplayer example then it would go in appMain.brs, right at the top, immediately after Sub Main()

You have to have the serialnumbers.txt file on your server before you launch the project. It doesn’t have to have any content yet, but it needs to be there.

- Joel

---

<div class="post-metadata">

**Author:** ![Biju](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@Biju](https://forum.developer.roku.com/u/Biju)\
**Post date:** [February 2, 2012, 7:18am UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/9 "2012-02-02T07:18:25Z")

</div>

> “RokuJoel” wrote:  
> Depends on which sample application you based your project on. If it is the videoplayer example then it would go in appMain.brs, right at the top, immediately after Sub Main()
> 
> You have to have the serialnumbers.txt file on your server before you launch the project. It doesn’t have to have any content yet, but it needs to be there.
> 
> - Joel  
> Than you Joel for supporting i’ll try this sample. Thank you

---

<div class="post-metadata">

**Author:** ![bandal](https://avatars.discourse-cdn.com/v4/letter/b/c67d28/32.png) [@bandal](https://forum.developer.roku.com/u/bandal)\
**Post date:** [February 2, 2012, 4:31pm UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/10 "2012-02-02T16:31:18Z")

</div>

I can confirm it does work. Thanks

---

<div class="post-metadata">

**Author:** ![Biju](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@Biju](https://forum.developer.roku.com/u/Biju)\
**Post date:** [February 5, 2012, 7:15am UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/11 "2012-02-05T07:15:02Z")

</div>

yes it did. can i add youtube on my private channel?

---

<div class="post-metadata">

**Author:** ![bandal](https://avatars.discourse-cdn.com/v4/letter/b/c67d28/32.png) [@bandal](https://forum.developer.roku.com/u/bandal)\
**Post date:** [February 5, 2012, 4:06pm UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/12 "2012-02-05T16:06:40Z")

</div>

You can if you want. RateRix is one channel for that and is private.

---

<div class="post-metadata">

**Author:** ![YungBlood](https://avatars.discourse-cdn.com/v4/letter/y/85f322/32.png) [@YungBlood](https://forum.developer.roku.com/u/YungBlood)\
**Post date:** [February 5, 2012, 8:51pm UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/13 "2012-02-05T20:51:50Z")

</div>

From what I understand, there are legal issues regarding youtube & ads. If you try play videos from youtube without displaying their ads, they get upset and can delete your account & videos. This has been discussed in much more detail in other theads.

---

<div class="post-metadata">

**Author:** ![Biju](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@Biju](https://forum.developer.roku.com/u/Biju)\
**Post date:** [February 7, 2012, 5:30am UTC](https://forum.developer.roku.com/t/does-anybody-have-the-code-for-linking-roku-device-to-websit/1599/14 "2012-02-07T05:30:39Z")

</div>

how can i add youtube as a category as other videos in my private channel
