It took me a while to figure out the structure of the API documentation. Once I figured out that the actual API calls were available via the links under "Supported Interfaces", I caught on quickly.
For future devs struggling with this issue, here's what I did. As I mentioned before, my channel is based on the "videoplayer" example. The following code is based on the "categoryFeed.brs" file. You will notice stark similarities upon comparison.
The following code is great for loading unencrypted resources, but not encrypted resources, so comment it out or delete it.
Function load_category_feed(conn As Object) As Dynamic
'** Make an http object to retrieve the unencrypted resource
'http = NewHttp(conn.UrlCategoryFeed)
'Dbg("url: ", http.Http.GetUrl())
I wanted access to an encrypted resource. Here is where setting up the roUrlTransfer object is necessary:
'** Make the category feed work with an encrypted resource
https = CreateObject("roUrlTransfer")
https.SetUrl(conn.UrlCategoryFeed)
https.SetCertificatesFile("common:/certs/ca-bundle.crt")
https.AddHeader("X-Roku-Reserved-Dev-Id", "")
https.InitClientCertificates()
Then it is quite necessary to use it. Notice the API call is slightly different on the roUrlTransfer object. There is no "GetToStringWithRetry" function, just "GetToString".
m.Timer.Mark()
'** The unencrypted response
'rsp = http.GetToStringWithRetry()
'** The encrypted response
rsps = https.GetToString()
Dbg("Took: ", m.Timer)
Previously, I overlooked what the roXMLElement was doing. It takes a response as an argument and parses the response. So I changed it to parse my new encrypted response (rsps) instead of the unencrypted response (rsp).
m.Timer.Mark()
xml=CreateObject("roXMLElement")
'** Parse the encrypted response (rsps) or unencrypted response (rsp)
if not xml.Parse(rsps) then
print "Can't parse feed"
return invalid
endif
Dbg("Parse Took: ", m.Timer)
There are other files you will need to modify if you too base your channel on the "videoplayer" example. roPosterScreen objects also support the ifHttpAgent interface. If you load banner ads from an encrypted resource,
sdAdUrl = "https:// ..."
hdAdUrl = "https:// ..."
screen.SetAdUrl(sdAdUrl, hdAdUrl)
'** Make the screen work with encrypted resources
screen.SetCertificatesFile("common:/certs/ca-bundle.crt")
screen.AddHeader("X-Roku-Reserved-Dev-Id", "")
screen.InitClientCertificates()
screen.setAdDisplayMode("scale-to-fit")
screen.Show()
In total, I made similar changes in categoryFeed.brs, appPosterScreen.brs, appHomeScreen.brs, and showFeed.brs. Hopefully this helps you out if you are currently facing the same questions I was.
Abe