irimiNage
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2013
10:41 PM
Help getting cookies using ifHttpAgent?
Hi,
I'm new to BrightScript but trying to put together a proof of concept for Roku as a streaming client for IP VOD from my employer, a paytv broadcaster. I'm trying to grab a session id from a cookie on our website so I can pass it back as part of a JSON login data structure but I'm really struggling to get more than the header and body back from the server. This is my best attempt so far: I can only make the GetCookies call at the expense of not getting the header and body, and I still don't get any cookies :(. Any help appreciated ....
I'm new to BrightScript but trying to put together a proof of concept for Roku as a streaming client for IP VOD from my employer, a paytv broadcaster. I'm trying to grab a session id from a cookie on our website so I can pass it back as part of a JSON login data structure but I'm really struggling to get more than the header and body back from the server. This is my best attempt so far: I can only make the GetCookies call at the expense of not getting the header and body, and I still don't get any cookies :(. Any help appreciated ....
url = "http://www.geekzone.co.nz"
request = CreateObject("roUrlTransfer")
request.SetUrl( url )
request.EnableCookies()
request.EnableFreshConnection(true)
xport=CreateObject("RoMessagePort")
request.setport(xport)
if (request.asyncPostFromSTring("t"))
'"request.async is true"
msg = wait(0,xport)
'"we should have a message"
if type(msg) = "roUrlEvent"
'"ok we have a url event"
hedone={}
hedtwo={}
hedone=msg.GetResponseHeadersArray()
hedtwo=msg.GetResponseHeaders()
body=msg.GetString()
code=msg.GetResponseCode()
event={result:hedone, headers:hedtwo, body:body, code:code}
end if
end if
'html = request.GetToString()
'print html
'print "len body = ", len(body)
print "getting geekzone cookies"
cookies = request.GetCookies( ".geekzone.co.nz", "/" )
print "printing geekzone cookies"
for each cookie in cookies
print cookie
end for
3 REPLIES 3

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2013
10:59 PM
Re: Help getting cookies using ifHttpAgent?
What the.. what? When did they add cookie support to ifHttpAgent? :shock:
Edit: I've never used it (obviously), so I can't answer directly how to use GetCookies, but you could just pull the cookie directly from the headers you retrieved when you got the content.
Edit: I've never used it (obviously), so I can't answer directly how to use GetCookies, but you could just pull the cookie directly from the headers you retrieved when you got the content.
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)
irimiNage
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2013
12:03 AM
Re: Help getting cookies using ifHttpAgent?
Thanks for the quick response. I initially tried some cut'n'paste hackery around parsing headers for cookies before I found the GetCookies call. For some reason (maybe redirects, not sure) I couldn't see the Set-Cookie in the headers returned. I've got a little python script that shows geekzone returns a cookie on their main page so I'll go back to that & see if I can parse a cookie out of the header on the Roku. Cheers
bosborne
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2013
11:32 AM
Re: Help getting cookies using ifHttpAgent?
Did you ever figure out how to get Cookies to print out?