Posting to Twitter on Android

Hi guys! 

I am pretty new to Corona SDK and recently I encounter some problems regarding on posting from the game to twitter. I downloaded the sample code for twitter in the Corona file and what I did was changed the values of the API Key and secret and nothing else.

The problems I encounter was

  1. It shows “Not Connected” at the bottom of the screen

**2) Whenever I press the “Tweet” button it shows “Failed: Invalid Token”

I’m using Corona Simulator.

What should I do so that when I press the “Tweet” button it posts the tweet on to my twitter? 

Can someone guide me through this?

Thank You!

Anyone can help?? Please…

Someone help me…???

You might want to put in some print statements to see what’s going on.  You also need to go back to twitter and make sure everything is enabled correctly.  The last time I set up a twitter app, there was a hidden checkbox or radio button you have to scroll down to get to.

Thank You for your reply. I will go and check it out

@Rob 

Do u mean the checkbox for “Sign in with Twitter”? I have checked that button but it still does not work.

It still shows “Failed: Invalid Token” when I press on the “Tweet” button and would not let me post to my twitter. 

Can someone guide me through this??

On the Twitter API page you have to fill out all four fields:

twitter1.png

The call back address is important.  What you put there doesn’t really matter.  That is you don’t have to have a website with that address.  It’s used as a string match in the oAUTH code.  If you don’t have a website, make up something.  The Corona Twitter sample app uses http://coronalabs.com so if you don’t have your own website, using that might be your best choice.

Then make sure to check the I Agree box:

twitter2.png

Then if you want to post to twitter, you have to enable write permission by visiting the Permissions tab and picking “Read and Write”.

If you’re testing the Corona SDK Twitter Sample app, open the Twitter.lua file and change the consumer_key and consumer_secret lines from nil to your value from the Twitter API page in quotes.  If you copy/paste it may insert an extra space at the beginning.  Make sure to remove it.

Change the webURL line to match whatever you put in the Callback URL field exactly.

I just did this and it worked as expected. 

Rob

Thank for your help Rob!

Greatly appreciated it  :)

Anyone can help?? Please…

Someone help me…???

You might want to put in some print statements to see what’s going on.  You also need to go back to twitter and make sure everything is enabled correctly.  The last time I set up a twitter app, there was a hidden checkbox or radio button you have to scroll down to get to.

Thank You for your reply. I will go and check it out

@Rob 

Do u mean the checkbox for “Sign in with Twitter”? I have checked that button but it still does not work.

It still shows “Failed: Invalid Token” when I press on the “Tweet” button and would not let me post to my twitter. 

Can someone guide me through this??

On the Twitter API page you have to fill out all four fields:

twitter1.png

The call back address is important.  What you put there doesn’t really matter.  That is you don’t have to have a website with that address.  It’s used as a string match in the oAUTH code.  If you don’t have a website, make up something.  The Corona Twitter sample app uses http://coronalabs.com so if you don’t have your own website, using that might be your best choice.

Then make sure to check the I Agree box:

twitter2.png

Then if you want to post to twitter, you have to enable write permission by visiting the Permissions tab and picking “Read and Write”.

If you’re testing the Corona SDK Twitter Sample app, open the Twitter.lua file and change the consumer_key and consumer_secret lines from nil to your value from the Twitter API page in quotes.  If you copy/paste it may insert an extra space at the beginning.  Make sure to remove it.

Change the webURL line to match whatever you put in the Callback URL field exactly.

I just did this and it worked as expected. 

Rob

Thank for your help Rob!

Greatly appreciated it  :)