elmik3
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017
01:12 PM
can't parse feed from https
Hi, I have this url feed example:
and sub categories example:
but when i use https protocol cant parse de xml file, in httpprotocol woks fine, this is my log from roku debug console:
this is my ctegoryFeed.brs code:
Someone who can help me please?
http://125.255.214.45/categoria.xml
and sub categories example:
https://125.255.214.45/categoria/movies.xml
but when i use https protocol cant parse de xml file, in httpprotocol woks fine, this is my log from roku debug console:
Took: 670ms
Parse Took: 0ms
begin category node parsing
number of categories: 8
ParseCategoryNode: category
category: Entretenimiento | Canales de entretenimiento
BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: pkg:/source/categoryFeed.brs(179)
added new child node
ParseCategoryNode: category
category: Deportes | Canales de deportes
BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: pkg:/source/categoryFeed.brs(179)
added new child node
ParseCategoryNode: category
category: Cine | Canales de cine
BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: pkg:/source/categoryFeed.brs(179)
added new child node
ParseCategoryNode: category
category: Infantiles | Canales infantiles
BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: pkg:/source/categoryFeed.brs(179)
added new child node
ParseCategoryNode: category
category: Cultura | Canales de cultura
BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: pkg:/source/categoryFeed.brs(179)
added new child node
ParseCategoryNode: category
category: TVAbierta | Canales tvabierta
BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: pkg:/source/categoryFeed.brs(179)
added new child node
ParseCategoryNode: category
category: Musica | Canales musica
BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: pkg:/source/categoryFeed.brs(179)
added new child node
ParseCategoryNode: category
category: Internacionales | Canales musica
BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: pkg:/source/categoryFeed.brs(179)
added new child node
Traversing: 6ms
this is my ctegoryFeed.brs code:
'******************************************************
'** RokuChannelMaker Template
'** 2014
'** Copyright (c) 2014 RokuChannelMaker.com All Rights Reserved.
'******************************************************
'******************************************************
' Set up the category feed connection object
' This feed provides details about top level categories
'******************************************************
Function InitCategoryFeedConnection() As Object
uniqueDeviceId=CreateObject("roDeviceInfo").GetDeviceUniqueId()
conn = CreateObject("roAssociativeArray")
conn.UrlPrefix = "149.25.24.25:8080/ROKU"
'conn.UrlCategoryFeed = conn.UrlPrefix + "/categories.xml"
conn.UrlCategoryFeed = conn.UrlPrefix + "/" + uniqueDeviceId + "/categories.xml"
conn.Timer = CreateObject("roTimespan")
conn.LoadCategoryFeed = load_category_feed
conn.GetCategoryNames = get_category_names
print "created feed connection for " + conn.UrlCategoryFeed
return conn
End Function
'*********************************************************
'** Create an array of names representing the children
'** for the current list of categories. This is useful
'** for filling in the filter banner with the names of
'** all the categories at the next level in the hierarchy
'*********************************************************
Function get_category_names(categories As Object) As Dynamic
categoryNames = CreateObject("roArray", 100, true)
for each category in categories.kids
'print category.Title
categoryNames.Push(category.Title)
next
return categoryNames
End Function
'******************************************************************
'** Given a connection object for a category feed, fetch,
'** parse and build the tree for the feed. the results are
'** stored hierarchically with parent/child relationships
'** with a single default node named Root at the root of the tree
'******************************************************************
Function load_category_feed(conn As Object) As Dynamic
http = NewHttp(conn.UrlCategoryFeed)
Dbg("url: ", http.Http.GetUrl())
m.Timer.Mark()
rsp = http.GetToStringWithRetry()
Dbg("Took: ", m.Timer)
m.Timer.Mark()
xml=CreateObject("roXMLElement")
if not xml.Parse(rsp) then
print "Can't parse feed"
return invalid
endif
Dbg("Parse Took: ", m.Timer)
m.Timer.Mark()
if xml.category = invalid then
print "no categories tag"
return invalid
endif
if islist(xml.category) = false then
print "invalid feed body"
return invalid
endif
if xml.category[0].GetName() <> "category" then
print "no initial category tag"
return invalid
endif
topNode = MakeEmptyCatNode()
topNode.Title = "root"
topNode.isapphome = true
print "begin category node parsing"
categories = xml.GetChildElements()
print "number of categories: " + itostr(categories.Count())
for each e in categories
o = ParseCategoryNode(e)
if o <> invalid then
topNode.AddKid(o)
print "added new child node"
else
print "parse returned no child node"
endif
next
Dbg("Traversing: ", m.Timer)
return topNode
End Function
'******************************************************
'MakeEmptyCatNode - use to create top node in the tree
'******************************************************
Function MakeEmptyCatNode() As Object
return init_category_item()
End Function
'***********************************************************
'Given the xml element to an <Category> tag in the category
'feed, walk it and return the top level node to its tree
'***********************************************************
Function ParseCategoryNode(xml As Object) As dynamic
o = init_category_item()
print "ParseCategoryNode: " + xml.GetName()
'PrintXML(xml, 5)
'parse the curent node to determine the type. everything except
'special categories are considered normal, others have unique types
if xml.GetName() = "category" then
print "category: " + xml@title + " | " + xml@description
o.Type = "normal"
o.Title = xml@title
o.Description = xml@Description
o.ShortDescriptionLine1 = xml@Title
o.ShortDescriptionLine2 = xml@Description
o.SDPosterURL = xml@sd_img
o.HDPosterURL = xml@hd_img
o.Feed = xml@feed
else if xml.GetName() = "categoryLeaf" then
o.Type = "normal"
else if xml.GetName() = "specialCategory" then
if invalid <> xml.GetAttributes() then
for each a in xml.GetAttributes()
if a = "type" then
o.Type = xml.GetAttributes()[a]
print "specialCategory: " + xml@type + "|" + xml@title + " | " + xml@description
o.Title = xml@title
o.Description = xml@Description
o.ShortDescriptionLine1 = xml@Title
o.ShortDescriptionLine2 = xml@Description
o.SDPosterURL = xml@sd_img
o.HDPosterURL = xml@hd_img
o.Feed = xml@feed
endif
next
endif
else
print "ParseCategoryNode skip: " + xml.GetName()
return invalid
endif
'only continue processing if we are dealing with a known type
'if new types are supported, make sure to add them to the list
'and parse them correctly further downstream in the parser
while true
if o.Type = "normal" exit while
if o.Type = "special_category" exit while
print "ParseCategoryNode unrecognized feed type"
return invalid
end while
'get the list of child nodes and recursed
'through everything under the current node
for each e in xml.GetBody()
name = e.GetName()
if name = "category" then
print "category: " + e@title + " [" + e@description + "]"
kid = ParseCategoryNode(e)
kid.Title = e@title
kid.Description = e@Description
kid.ShortDescriptionLine1 = xml@Description
kid.SDPosterURL = xml@sd_img
kid.HDPosterURL = xml@hd_img
kid.Feed = e@feed
o.AddKid(kid)
else if name = "categoryLeaf" then
print "categoryLeaf: " + e@title + " [" + e@description + "]"
kid = ParseCategoryNode(e)
kid.Title = e@title
kid.Description = e@Description
kid.Feed = e@feed
o.AddKid(kid)
else if name = "specialCategory" then
print "specialCategory: " + e@title + " [" + e@description + "]"
kid = ParseCategoryNode(e)
kid.Title = e@title
kid.Description = e@Description
kid.sd_img = e@sd_img
kid.hd_img = e@hd_img
kid.Feed = e@feed
o.AddKid(kid)
endif
next
return o
End Function
'******************************************************
'Initialize a Category Item
'******************************************************
Function init_category_item() As Object
o = CreateObject("roAssociativeArray")
o.Title = ""
o.Type = "normal"
o.Description = ""
o.Kids = CreateObject("roArray", 100, true)
o.Parent = invalid
o.Feed = ""
o.IsLeaf = cn_is_leaf
o.AddKid = cn_add_kid
return o
End Function
'********************************************************
'** Helper function for each node, returns true/false
'** indicating that this node is a leaf node in the tree
'********************************************************
Function cn_is_leaf() As Boolean
if m.Kids.Count() > 0 return true
if m.Feed <> "" return false
return true
End Function
'*********************************************************
'** Helper function for each node in the tree to add a
'** new node as a child to this node.
'*********************************************************
Sub cn_add_kid(kid As Object)
if kid = invalid then
print "skipping: attempt to add invalid kid failed"
return
endif
kid.Parent = m
m.Kids.Push(kid)
End Sub
Someone who can help me please?
11 REPLIES 11
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017
01:30 PM
Re: can't parse feed from https
Make sure you call SetCertificatesFile("common:/certs/ca-bundle.crt") on the roUrlTransfer object used to access the feed.
elmik3
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2017
08:07 PM
Re: can't parse feed from https
"belltown" wrote:
Make sure you call SetCertificatesFile("common:/certs/ca-bundle.crt") on the roUrlTransfer object used to access the feed.
Thanks for replying, I just wanted to use amazon s3 bucket for this purpose, my doubt was because in the general category works fine (https://125.255.214.45/categoria.xml), but in my subcategories not (https://125.255.214.45/categoria/movies.xml).
I not have my own cert file, thanks anyway.
elmik3
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017
01:03 PM
Re: can't parse feed from https
"belltown" wrote:
Make sure you call SetCertificatesFile("common:/certs/ca-bundle.crt") on the roUrlTransfer object used to access the feed.
hello again, i read this post and i put my code this way:
Function CreateURLTransferObject(url As String) as Object
obj = CreateObject("roUrlTransfer")
obj.SetPort(CreateObject("roMessagePort"))
obj.SetCertificatesFile ("pkg:/certs/server.crt")
obj.InitClientCertificates ()
obj.AddHeader("X-Roku-Reserved-Dev-Id", "")
obj.SetUrl(url)
obj.AddHeader("Content-Type", "application/x-www-form-urlencoded")
obj.EnableEncodings(true)
return obj
End Function
but i have this error:
------ Running dev 'CloudStream' main ------
created feed connection for https://mydomain.pw/categories.xml
url: [size=85][font=monospace]https://mydomain.pw/categories.xml[/font][/size]
Took: 207ms
Can't parse feed
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.
Current Function:
037: Function get_category_names(categories As Object) As Dynamic
038:
039: categoryNames = CreateObject("roArray", 100, true)
040:
041:* for each category in categories.kids
042: 'print category.Title
043: categoryNames.Push(category.Title)
044: next
045:
Syntax Error. (runtime error &h02) in pkg:/source/categoryFeed.brs(41)
041: for each category in categories.kids
Backtrace:
#3 Function get_category_names(categories As Object) As Dynamic
file/line: pkg:/source/categoryFeed.brs(41)
#2 Function initcategorylist() As Void
file/line: pkg:/source/appHomeScreen.brs(112)
#1 Function showhomescreen(screen As Dynamic) As Integer
file/line: pkg:/source/appHomeScreen.brs(39)
#0 Function main() As Void
file/line: pkg:/source/appMain.brs(20)
Local Variables:
categories bsc:roInvalid refcnt=1
global Interface:ifGlobal
m roAssociativeArray refcnt=3 count:5
categorynames roArray refcnt=1 count:0
category <uninitialized>
here is my pkg:/source/categoryFeed.brs(41) code:
Function load_category_feed(conn As Object) As Dynamic
http = NewHttp(conn.UrlCategoryFeed)
Dbg("url: ", http.Http.GetUrl())
m.Timer.Mark()
rsp = http.GetToStringWithRetry()
Dbg("Took: ", m.Timer)
m.Timer.Mark()
xml=CreateObject("roXMLElement")
if not xml.Parse(rsp) then
print "Can't parse feed"
return invalid
endif
Dbg("Parse Took: ", m.Timer)
m.Timer.Mark()
if xml.category = invalid then
print "no categories tag"
return invalid
endif
if islist(xml.category) = false then
print "invalid feed body"
return invalid
endif
if xml.category[0].GetName() <> "category" then
print "no initial category tag"
return invalid
endif
topNode = MakeEmptyCatNode()
topNode.Title = "root"
topNode.isapphome = true
print "begin category node parsing"
categories = xml.GetChildElements()
print "number of categories: " + itostr(categories.Count())
for each e in categories
o = ParseCategoryNode(e)
if o <> invalid then
topNode.AddKid(o)
print "added new child node"
else
print "parse returned no child node"
endif
next
Dbg("Traversing: ", m.Timer)
return topNode
End Function
somebody helpme :cry: 😞
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017
01:50 PM
Re: can't parse feed from https
Did you try outputting the response and make sure it's well-formed XML? Add a "print rsp" just before that line that reads
and see what you're getting back (a server error perhaps? Or XML with symbols Roku doesn't like?).
print "Can't parse feed"
and see what you're getting back (a server error perhaps? Or XML with symbols Roku doesn't like?).
aspiring
elmik3
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017
02:05 PM
Re: can't parse feed from https
"joetesta" wrote:
Did you try outputting the response and make sure it's well-formed XML? Add a "print rsp" just before that line that readsprint "Can't parse feed"
and see what you're getting back (a server error perhaps? Or XML with symbols Roku doesn't like?).
this is the error:
Syntax Error. (runtime error &h02) in pkg:/source/categoryFeed.brs(40)
040: for each category in categories.kids
and this is the function code:
Function get_category_names(categories As Object) As Dynamic
categoryNames = CreateObject("roArray", 100, true)
for each category in categories.kids
'print category.Title
categoryNames.Push(category.Title)
next
return categoryNames
End Function
the xml file works fine and i validate in https://www.xmlvalidation.com/, another sugestion?
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017
02:53 PM
Re: can't parse feed from https
categories bsc:roInvalid refcnt=1
The "categories" value you're sending is not valid.. If you're willing to post the rsp as I suggested above, that may expedite troubleshooting.
aspiring
elmik3
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017
03:13 PM
Re: can't parse feed from https
"joetesta" wrote:categories bsc:roInvalid refcnt=1
The "categories" value you're sending is not valid.. If you're willing to post the rsp as I suggested above, that may expedite troubleshooting.
ok i put this line to see the response in debug console with https protocol:
Dbg("respuesta: ", rsp)
debug console:
------ Running dev 'CloudStream' main ------
created feed connection for https://mysite/categories.xml
url: https://mysite/categories.xml
Took: 369ms
respuesta:
Can't parse feed
and only with http protocol:
------ Running dev 'CloudStream' main ------
created feed connection for http://mysite/categories.xml
url: http://mysite/categories.xml
Took: 654ms
respuesta: <?xml version="1.0" encoding="UTF-8"?>
<categories>
<category
title="Entretenimiento"
description="Canales de entretenimiento"
sd_img="http://mysite/xml/entretenimiento.png"
hd_img="http://mysite/xml/entretenimiento.png"
feed="http://mysite/xml/entretenimiento.xml"
/>
</categories>
what am I doing wrong?
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017
03:17 PM
Re: can't parse feed from https
you're not getting a response via https. Based on your earlier comments, it sounds like your cert is working, but in that case you should have the same response, no? (i assume you tested this in a browser) May be worth trying belltown's suggestion once.
aspiring
elmik3
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017
03:29 PM
Re: can't parse feed from https
"joetesta" wrote:
you're not getting a response via https. Based on your earlier comments, it sounds like your cert is working, but in that case you should have the same response, no? (i assume you tested this in a browser) May be worth trying belltown's suggestion once.
thanks for your quick response; In the browser the url (https) works correctly and the certificate is valid, And in reference to the belltown's suggestion i Modify my code like this Based on this post: https://forums.roku.com/viewtopic.php?t=96393, so I do not know what else to do,
Function CreateURLTransferObject(url As String) as Object
obj = CreateObject("roUrlTransfer")
obj.SetPort(CreateObject("roMessagePort"))
obj.SetCertificatesFile ("pkg:/certs/server.crt")
obj.InitClientCertificates ()
obj.AddHeader("X-Roku-Reserved-Dev-Id", "")
obj.SetUrl(url)
obj.AddHeader("Content-Type", "application/x-www-form-urlencoded")
obj.EnableEncodings(true)
return obj
End Function