mdesplanches
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016
09:46 AM
Graph XML: use roUrlTransfer
Hello everyone,
I'm new on Roku plateform and I have some questions about XML component functionality !
I am getting a json with roUrlTransfer, and I printed correctly inside value.
But I wanted to use json response object in XML component file, like:
But the program is stuck at response = getJson line, anyone have an alternative to use my json inside graph XML ?
Thanks in advance !
Max
I'm new on Roku plateform and I have some questions about XML component functionality !
I am getting a json with roUrlTransfer, and I printed correctly inside value.
Function getJson() As Object
searchRequest = CreateObject("roUrlTransfer")
searchRequest.SetCertificatesFile("common:/certs/ca-bundle.crt")
searchRequest.AddHeader("X-Roku-Reserved-Dev-Id", "")
searchRequest.InitClientCertificates()
searchRequest.SetURL("https://api.tfoumax.fr/catalog/home")
response = ParseJson(searchRequest.GetToString())
return response
End Function
But I wanted to use json response object in XML component file, like:
<?xml version="1.0" encoding="utf-8" ?>
<component name = "myrowlist" extends = "ContentNode" >
<script type = "text/brightscript" uri = "pkg:/source/getJson.brs" />
<script type="text/brightscript" >
<![CDATA[
sub init()
response = getJson()
end sub
]]>
</script>
</component>
But the program is stuck at response = getJson line, anyone have an alternative to use my json inside graph XML ?
Thanks in advance !
Max
4 REPLIES 4

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016
09:56 AM
Re: Graph XML: use roUrlTransfer
You can't create an roUrlTransfer object in the main SceneGraph thread. You'll need to move that into a Task node.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
mdesplanches
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016
10:33 AM
Re: Graph XML: use roUrlTransfer
Thanks your for your reactivity ! I am using now a task but it fail on SetCertificatesFile("common:/certs/ca-bundle.crt"), (not failed in brs file)
telnet:
Run task:
Thanks again for your help
telnet:
Backtrace:
#0 Function init() As Void
file/line: ...AAA8F92yB/pkg:/components/getJson.xml(17)
Local Variables:
global rotINTERFACE:ifGlobal
m roAssociativeArray refcnt=3 count:1
searchrequest Invalid
<?xml version="1.0" encoding="utf-8" ?>
<component name="getJsonGraph" extends="Task" >
<interface>
<field id="json-api" type="string" />
</interface>
<script type="text/brightscript" >
<![CDATA[
sub init()
searchRequest = CreateObject("roUrlTransfer")
searchRequest.SetCertificatesFile("common:/certs/ca-bundle.crt")
searchRequest.AddHeader("X-Roku-Reserved-Dev-Id", "")
searchRequest.InitClientCertificates()
searchRequest.SetURL("myapi-url")
response = ParseJson(searchRequest.GetToString())
For Each categorie In response.categories
print categorie.title
End For
end sub
]]>
</script>
</component>
Run task:
<?xml version="1.0" encoding="utf-8" ?>
<component name = "rowlistcontent" extends = "ContentNode" >
<script type="text/brightscript" >
<![CDATA[
sub init()
m.simpleTask = CreateObject("roSGNode", "getJsonGraph")
m.simpleTask.control = "RUN"
end sub
]]>
</script>
<children>
</children>
</component>
Thanks again for your help

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016
11:34 AM
Re: Graph XML: use roUrlTransfer
For Task nodes, you need to set m.top.functionName in init(). That indicates which function will be run in the Task thread when you set the control to RUN. It's that function that will run in the separate thread and allow you to create the roUrlTransfer object.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
mdesplanches
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2016
01:51 AM
Re: Graph XML: use roUrlTransfer
Thanks you, it works !