Connecting to https in Lua, Help needed
Posted: 19 May 2012 13:14
I'm tinkering with the idea of reading messages live from twitter (from a group of people simultaneously watching a movie) and using osd to show them as if they were subtitles...
The hangup is that Twitter's live API only accepts a POST request over https.
VLC's lua can do a GET by letting an access module do all the work...
This would be great but the access module won't POST.
Note: Some servers run afoul of gnutls root cert issues, but luckily not the google test url above or twitter, on my system. Incidentally certs are read from a file (~/.vlc/ssl/certs/ca-certificates.crt) on linux and a MMC snap-in (certmgr.msc) on windows.
The alternative seems to be vlc.net.connect_tcp(host, port), but that looks like I'd have to handle TLS myself.
For the curious, here's the easy way to query Twitter.*
Lookup a user's numeric id to hardcode in a script (look for /user/id)...
curl -d "follow=THAT_ID" "https://YOUR_USER:YOUR_PASS@stream.twit ... ilter.json"
Then you get a continuous line-oriented json of tweets as they happen. This'll be pretty quiet unless an event is planned.
I just can't figure out how to send that "follow=012345" POST data.
Tantalizingly, I can use the access module to GET a rather overwhelming sample stream intended for testing.
curl "https://YOUR_USER:YOUR_PASS@dev.twitter ... ses/sample"
That'll result in a very busy terminal.
* The more elaborate OAuth method is what's officially recommended; if I can get this working, I can reference the Share on Twitter extension for that.
The hangup is that Twitter's live API only accepts a POST request over https.
VLC's lua can do a GET by letting an access module do all the work...
Code: Select all
local stream = vlc.stream("https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt")
local data = ""
while data do
data = stream:read(65536)
vlc.msg.dbg("[appname] ".. data)
break
end
Note: Some servers run afoul of gnutls root cert issues, but luckily not the google test url above or twitter, on my system. Incidentally certs are read from a file (~/.vlc/ssl/certs/ca-certificates.crt) on linux and a MMC snap-in (certmgr.msc) on windows.
The alternative seems to be vlc.net.connect_tcp(host, port), but that looks like I'd have to handle TLS myself.
For the curious, here's the easy way to query Twitter.*
Lookup a user's numeric id to hardcode in a script (look for /user/id)...
Code: Select all
https://api.twitter.com/1/users/show.xml?screen_name=CHANGE_ME
or
https://api.twitter.com/1/users/show.json?screen_name=CHANGE_ME
Then you get a continuous line-oriented json of tweets as they happen. This'll be pretty quiet unless an event is planned.
I just can't figure out how to send that "follow=012345" POST data.
Tantalizingly, I can use the access module to GET a rather overwhelming sample stream intended for testing.
curl "https://YOUR_USER:YOUR_PASS@dev.twitter ... ses/sample"
That'll result in a very busy terminal.
* The more elaborate OAuth method is what's officially recommended; if I can get this working, I can reference the Share on Twitter extension for that.