Forum Discussion

squirreltown's avatar
squirreltown
Roku Guru
13 years ago

RSS parse

I have an rss feed working fine from an http GET request from the Roku. I am trying to change it to http POST. I am getting an error and the feed isnt being parsed. I know the rss feed is outputting the proper format/info from the POST request, but am having trouble capturing it back at the Roku.
Here is the error
<br />
Found error in the file '<b>/home/phcom/public_html/web/rss13/index3.php</b>' at line <b>30</b>.<br />
Called '<b>getAll</b>' function with erroneous argument #<b>0</b>.<br /><br />

and the calling function:
Function  SendFavsViaPost(feed_url)

strx = ReadAsciiFile("tmp:/apfavorites")

m.http.SetUrl(feed_url)
m.http.PostFromString("AID=" + strx)
xml=m.http.GetToString()

print xml

rss=CreateObject("roXMLElement")
if not rss.Parse(xml) then stop
print "rss@version=";rss@version
pl=CreateObject("roList")
for each item in rss.channel.item
pl.Push(newPhotoFromXML(m.http, item))
print "photo title=";pl.Peek().GetTitle()
next
return pl

End Function

13 Replies

  • "squirreltown" wrote:
    yea I actually got that part right this time. This same function works fine if I change the POST stuff to GET, which is the way it is normally.

    Ive just changed
    m.http.SetUrl(feed_url)

    to
    strx = ReadAsciiFile("tmp:/apfavorites")
    m.http.SetUrl(feed_url)
    m.http.AsyncPostFromString("AID=" + strx)

    and
    xml=m.http.GetToString()

    to

    while true
    msg = Wait(8000, m.port )
    If msg = invalid Then
    print "Error: invalid"
    Else If Type( msg ) = "roUrlEvent" Then
    if msg.GetString()
    xml= msg.GetString()
    End If
    end if

    ...............


    it prints the error and crashes on the next block because the xml variable is empty

    That's actually a much bigger change that it may look. You went from the synchronous GetToString() to the asynchronous AsycnPostFromString() method. The former doesn't require a port and wait loop, while the second does, so I'd bet it is an issue with the port you're listening on. Try just swapping:
    xml = m.http.GetToString()
    with:
    xml = m.http.PostFromString("AID=" + strx)
    and see if it works. That's swapping synchronous for synchronous...
  • Thank you TheEndless & Mark- So it turns out to be a port issue after all. I thought the port was being set in the function that created it but i guess not. I added a setmessageport line and that led to it getting fixed, it runs fine now.
  • hello
    i want to send username and password in post form
    i not found any right way to do it kindly help me.
    i have username in one variable and password in other variable
    and i have url so how i send request to the server in post form