Easy Twitter integration

I thought you might find this a useful tip.

I spent ages with the oAuth code samples getting an app to send a simple tweet before I realised that there is an extremely simple way of doing, with no need to register your app with Twitter or use access keys. Use Twitter Web Intents (see the developer pages on the Twitter website for more details).

Just one line of code to send a tweet ...

1
native.showWebPopup(0, 0, 320, 480, "http://twitter.com/intent/tweet?text=My%20tweet%20goes%20here")

I'm bumping this to keep it on the front a bit longer.

Very valuable info for the many users wanting a simpler way to integrate Twitter.

Nicely done! :)

Great! Thanxxx

Michael

Cool, I think I'll use this for bragging about score. Thanks!

-Angelo

Thanks, Peach. I've been trying a similar thing with Facebook, using the Dialog URL (details here http://developers.facebook.com/docs/reference/dialogs/). It works rather well and also allows the user to edit their post. You need to set the display parameter to touch so that the dialog fits the screen nicely. If you're not logged on then you get the login dialog first.

Here's an example:

1
native.showWebPopup(0, 80, screenW, screenH-80, "http://www.facebook.com/dialog/feed?display=touch&redirect_uri=http://www.yourwebsite.com&app_id=" .. appId .. "&link=http://www.yourwebsite.com/yourapp&picture=http://www.yourwebsite.com/appicon.png&name=Your%20App&caption=iPhone%20app%20coming%20soon&description=Put%20your%20description%20text%20here&message=" .. messageText)

Hi Stefan,
I tried the Twitter and Facebook codes and they work.
But there is one thing that doesn't work properly.

After posting a twitter message the window closes correctly but after posting the Facebook message the popup window stays and displays the content of my website.

Do you know how to fix it please?

Thank you, :)
Dusan

Hi Dusan

As mentioned in my previous post, you need to make the popup window less than full-screen to leave a space to put a button that can be used to cancel the popup after posting your message. This is also useful if the user decides not to post the message or if there is a connection problem.

Hope that helps!

Stefan

I made it smaller and put the close button there.
I just wasn't sure if it's the right behavior that my web site appears in the web popup after the facebook message is sent. I wish the web popup would close itself as it does in the twitter case.

Thanks a lot!,
Dusan

I can't remember the exact behaviour but I thought you had to manually close the web popup for both the Twitter and Facebook examples. If you want this to happen automatically then I think you'll need to use the oAuth approach.

Stefan

Hi Stefan,
I just tested both examples (Facebook and Twitter) on Android device and found out that they crash after I try to login.

Have you tested it on Android and do you have the same experience?

Thanks,
Dusan

Hi Dusan

I haven't tested out the Facebook and Twitter examples on Android yet (I've only recently got an Android device) but I can't see any reason why they should not work. The code is essentially the same as is used to create simple website widgets, and is based on Facebook and Twitter documentation, with the Corona web popup acting as the medium.

I would suspect that the most likely cause of any failure would be not having the appropriate Internet permissions in the build.settings file. I can't recall the exact format details off the top of my head but there are several references to the settings required elsewhere on the Ansca forums and reference pages.

I'll try and have a go myself but let me know if you have any success.

Stefan

SO FRUSTRATING!!!

Twitter intents sometimes close the window, and sometimes they don't!!! Sometimes I get an ad for the Twitter iPad app, sometimes something else. Argh!!!!!

I built a close button and a background rect to hide the screen. That means, sometimes I'm left with a blank screen and a close button. Sure, it works, but it isn't elegant!!!!

Argh, I say.

He Mimetic, what Corona SDK build do you use?

D.

Unsure which version that was, I think a a two-week old "daily". I've just downloaded the latest daily build (2011.585). The issue seems to be on the Twitter side, what with their big ad and all. If they had a window like the Facebook window, with a close button, it might work better!

Hello,

I used the above code and it works great, but I can't get a hashtag to appear. Can someone provide a sample of how to properly do this?

Thanks.

Update: I figured it out!

uh. the facebook example worked like a charm a few days ago.
but now it's not working anymore!

the "message" isn't sent :(
but I changed nothing since the last successful test...

I try this:

1
http://www.facebook.com/dialog/feed?display=touch&redirect_uri=http://www.canupa.com/products&app_id=xxxxxxxxx&link=http://www.canupa.com/products/parallax&picture=http://www.canupa.com/images/stories/articles/appicon_parallax_80x80_01.png&name=PARALLAX&message=WOW!%20I%20scored%20100000%20in%20PARALLAX!%20RANK%3A%20A%20-%20challenge%20me!%20http%3A%2F%2Fitunes.apple.com%2Fapp%2Fparallax%2Fid445444981%3Fmt%3D8

this info was extremely helpful....for others looking for more information check this link on facebook about new changes in feed dialogs: http://developers.facebook.com/docs/reference/dialogs/feed/

here's another problem I stumbled upon regarding twitter web popups-

Lets say you have a string you want to tweet that looks like this:

1
message = "Hi everybody! This is a tweet full of space characters!"
views:2932 update:2011/10/15 14:27:43
corona forums © 2003-2011