Twitter OAuth

Wow. I’m so at a loss yet again.

First, can we request that the demo code for twitter be removed? The fact that it’s completely old and doesn’t even remotely work wasted a bit of my time and I’m sure the time of anyone who is looking to add twitter support to their apps.

Is there anyone who can help explain how to use the Oauth code that’s in the code exchange?
http://developer.anscamobile.com/code/oauth-library

I’ve tried it, but I haven’t the faintest idea what I’m supposed to do next. I’m getting an event.response of “unauthorized.”

What next? I set up my app with dev.twitter.com, I’ve got the consumer key and consumer secret loaded into the main.lua, and I used www.google.com as the options.token_ready_url

But what now? I don’t even know what unauthorized means! Did I set something up wrong on the twitter end of things? Is there better demo code anywhere that I can look at? Is there anyone that has a simple app that actually works with twitter Oauth?

Please help!

(Oh, and waiting for official support is not possible as I need this to work before next week) [import]uid: 37122 topic_id: 20236 reply_id: 320236[/import]

Hey Gigaflop,

This doesn’t use oAuth but should work fine for posting to Twitter, is it an option?

[lua]local function escape (s)
s = string.gsub(s, “([&=+%c])”, function ©
return string.format("%%%02X", string.byte©)
end)
s = string.gsub(s, " ", “+”)
return s
end

local tweetText = “This is the tweet message.”

local postBody = escape( tweetText )
local theNetwork = theNetwork or “twitter” – twitter is default

–local theString = string.gsub(message, “( )”, “%%20”)
if theNetwork == theNetwork or “twitter” then
native.showWebPopup(20, 20, display.contentWidth - 40, display.contentHeight - 90, “http://twitter.com/intent/tweet?text=”…postBody)
end[/lua]

I will bring up the Twitter code in our next meeting.

Peach :slight_smile: [import]uid: 52491 topic_id: 20236 reply_id: 79101[/import]

Ok, not the most elegant solution but it works! Thank you. [import]uid: 37122 topic_id: 20236 reply_id: 79513[/import]

No worries, hopefully we can sort out the Twitter stuff soon but in the mean time I’m glad this works for you.

Peach :slight_smile: [import]uid: 52491 topic_id: 20236 reply_id: 79654[/import]

Any update on getting OAuth to work for Twitter? I’ve tried all kinds of code but just can’t get it to work (both OAuth and xAuth). [import]uid: 43714 topic_id: 20236 reply_id: 84952[/import]

Ok I FINALLY got it to work. I was using http.request not knowing it doesn’t support https/ssl. Switched to network.request and it magically worked. Twitter uses https for all URLs these days, so it’s a must to use network.request. [import]uid: 43714 topic_id: 20236 reply_id: 84959[/import]

Hey - thanks for updating this, I’m sure it will help others in the future :slight_smile: [import]uid: 52491 topic_id: 20236 reply_id: 85127[/import]

@o.corduwener
Can you specify which library you used?
The oAuth library in Code Exchange? [import]uid: 64174 topic_id: 20236 reply_id: 100779[/import]

I used this one and edited it to my needs:

http://developer.anscamobile.com/code/oauth-library#comment-27644
http://developer.anscamobile.com/code/oauth-library#comment-27645 [import]uid: 43714 topic_id: 20236 reply_id: 100789[/import]