Twitter Sync

Guys how can I check if Twitter username and password are correct?

Thanks! :smiley: [import]uid: 7022 topic_id: 1578 reply_id: 301578[/import]

I’m not sure I understand the question.

Logging in would prove that the u/p is correct; do you want to check with out logging in for some reason? [import]uid: 3 topic_id: 1578 reply_id: 4518[/import]

In your Twitter example you can’t know if you write a wrong Twitter username and/or password, in fact the app show that tweet as sent but it was not. There’s no check. So I would like to know if I can check username and password before storing them into a file in my game.
It’s not like Facebook Connect, your Twitter example doesn’t use Twitter OAuth because there’s no API for Lua. [import]uid: 7022 topic_id: 1578 reply_id: 4520[/import]

Oh, I see what you mean now.

With the way twitter is doing auth for their json update api you would get a HTTP status code 401 if the u/p were bad. In the example that isn’t caught, but changing

http.request { url = "http://" .. username .. ":" .. password .. "@twitter.com/statuses/update.json", method = "POST", headers = headerTable, source = ltn12.source.string( postBody ) } to

b,c,h = http.request {   
url = "http://" .. username .. ":" .. password .. "@twitter.com/statuses/update.json",  
method = "POST",  
headers = headerTable,  
source = ltn12.source.string( postBody )  
}  

Would get you started down the path of being able to check

Here’s the lua socket docs for http.request for reference http://w3.impa.br/~diego/software/luasocket/http.html#request
We should probably update that example in the near future though, as twitter is also moving to oAuth.

[import]uid: 3 topic_id: 1578 reply_id: 4521[/import]

Thanks a lot seanh! [import]uid: 7022 topic_id: 1578 reply_id: 4523[/import]