sub init()
m.top.functionName = "executeTask"
vimeoClientID = "clientId"
vimeoClientSecret = "clientSecret+"
blob = CreateObject("roByteArray")
blob.FromAsciiString(vimeoClientID + ":" + vimeoClientSecret)
m.base64Vimeo = blob.ToBase64String()
end sub
function executeTask()
url = m.top.url
print("In execute task function")
request = CreateObject("roURLTransfer")
request.SetCertificatesFile("common:/certs/ca-bundle.crt")
request.AddHeader("X-Roku-Reserved-Dev-Id", "")
request.AddHeader("Authorization","basic " + m.base64Vimeo)
request.InitClientCertificates()
request.SetURL(url)
m.top.response = request.getToString()
m.top.request = url
end function
sub init()
m.requestTask = CreateObject("roSGNode", "RequestTask") [size=85][font=Helvetica Neue, Helvetica, Arial, sans-serif] [/font][/size]
end sub
sub makeURLRequest(props)
m.requestTask.setField("url", props.url)
m.requestTask.control = "RUN"
m.requestTask.observeField("response", props.callback)
end sub
sub getVimeoChannelVideosPage(page, callback)
print("Making request for page: " + page.toStr())
makeURLRequest({
url: "https://api.vimeo.com/channels/" + m.channel.id + "/videos?page=" + page.toStr(),
callback: callback,
})
end sub
sub getVimeoChannelVideos(callback)
getVimeoChannelVideosPage(1, "onGetVimeoVideosPage")
end sub
sub onGetVimeoVideosPage()
response = m.requestTask.response
json = parseJSON(response)
videos = json.data
nextPage = json.paging.next
if (nextPage <> invalid)
m.channel.currentPage += 1
print("Current page " + m.channel.currentPage.toStr())
getVimeoChannelVideosPage(m.channel.currentPage, "onGetVimeoVideosPage")
else
showScene(m.homeScene)
end if
end sub
sub makeURLRequest(props)
m.requestTask.control = "STOP"
m.requestTask.setField("url", props.url)
m.requestTask.control = "RUN"
m.requestTask.observeField("response", props.callback)
end sub
I am running this file in task.xml
<?xml version=“1.0” encoding=“utf-8" ?>
<!-- Copyright 2016 Roku Corp. All Rights Reserved. -->
<component name=“ContentReader” extends=“Task”>
<script type=“text/brightscript”>
<![CDATA[
sub init()
m.top.functionName = “getAPIResponse”
end sub
sub getAPIResponse()
port = CreateObject(“roMessagePort”)
request = CreateObject(“roUrlTransfer”)
request.setRequest(“GET”)
request.setURL(m.top.contenturi)
jsonString = request.GetToString()
jsonParsed = ParseJson(jsonString)
m.top.content = jsonParsed
end sub
]]>
</script>
</component>
And Used this below function in main.brs file
sub Main()
print “in showChannelSGScreen”
m.readXMLContentTask = createObject(“roSGNode”, “ContentReader”)
m.readXMLContentTask.observeField(“content”, “setcontent”)
m.readXMLContentTask.contenturi = “http://www.sdktestinglab.com/Tutorial/content/xmlcontent.xml”
m.readXMLContentTask.control = “RUN”
readData = m.top.content
print “readData”
end sub
but this function is not executed in main.brs file
Can you please help me to execute this function from main.brs Or provide the sample examples