Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My computer game is powered using Love2d in Lua, there is dead space in the menu of my game and I'd like to fill it up with something. So I'll like to put a twitter feed there, how can I receive all the twitter posts created by AND mentioned from @stickydestroyer; how can I make it look good and code the actual thing.

I know I have to use some sort of cURL module, but how can I get the feed AND make it looking nicely?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You'll probably want to use the REST API to recover a user timeline and/or a mentions timeline.

To make requests you'll probably want a socket and JSON API for Lua. You find a specific example involving the use of both of those APIs to talk to a different REST API (not Twitter's) here, which you can probably adapt to use for Twitter based on their documentation.

What you'll get from the Twitter endpoint is JSON data, which you can then format as appropriate to make it look nice within the context of your game.

share|improve this answer
    
Some pitfalls from having done similar things with the Facebook API: luasocket.http does not block, so you'll need to love.thread. LuaJSON is buggy with unicode characters, so you may have to fudge the results a bit. –  Anko Dec 6 '12 at 20:11
    
What do you mean it doesn't block? –  qaisjp Dec 7 '12 at 8:02
1  
It means the function will return to your code immediately but (in this case) the actual HTTP request may not be complete yet, because it's being carried out by another thread or something. By contrast a blocking call would involve waiting within the function until the request completed fully and the response was available to you. –  Josh Petrie Dec 7 '12 at 15:52
    
Oops, I typoed! luasocket.http does block! (So you'll need a thread.) The explanation from Josh is correct though. Sorry! –  Anko Dec 7 '12 at 16:53
    
Aha, so it "sleeps" until the value is returned. –  qaisjp Dec 7 '12 at 17:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.