thanks. I'll give it a shot.
1 person found this helpful
If you just want tweet function into an AIR IOS app, then you can use use the following link, only 3 line code. I have used it and it is working fine, the problem is that when you click on the twitter link browser will open and your application goes in pause mode in background, you have to resume it from the apps panel. If you're OK with it, then it will be nice link for you.
This seems very useful. I'll stick with this method till I figure out a way to implement a native tweet function into my app. Thanks a lot vipul !
Hey everyone, sorry for bringing this topic back again, but I hope I can find further assistance with this topic.
I did do Vipul's method, it worked great, but I'd like to develop it further into an in-app thing, where a user is prompt to login to send tweets.
I had a read on oAuth and tweetr, but I'm still quite lost as to what oAuth really means and how to use tweetr.
Through my understanding, oAuth sounds like one of thos "permission-asking" script where it asks your twitter account to allow permission for accessing your twitter account details or something like that.
Does that mean the user won't have to go through the username and password input thing?
Most of the tutorials are done in FLEX, unfortunately my project is mainly done in Flash Professional and I heard conversion to Flash Builder would be a disaster, not to mention my un-familiarity with flash Builder.
Yeah... hopefully someone can share some ideas on how you've used tweetr or anything similar to it. I'm just looking to build a simple twitter function where a small window pops up to prompt the user to login and send a tweet of their resulting score. (An excellent example would be Doodle Jump [Original, not Jump Star], at the end of the round, there's a twitter function).
Thank you very much!
1 person found this helpful
There are three levels of Twitter features you can add to your game. The amount of work required to add features from these levels increases as the feature level increases.
The first and easiest feature level is adding one (or more) of four Twitter buttons to your embedding html.
If you go to https://twitter.com/about/resources/buttons you can pick one (or more) of those four buttons and generate the code needed to add them to your embedding html. Just follow the directions and copy and paste the rendered code into your html document.
The second and third feature level requires use of Twitter's REST API, https://dev.twitter.com/docs/api. The difference between, what I call, the second and third level is that second level REST API requests require no authentication while third level requests require authentication.
To determine if you need to use authentication, check the REST API. It looks like there are less than 150 resource requests you can make from Twitter at the time of this writing so it is easy to scan the list to see what requests you need for your game.
Click on each request you need to see details of the request. Towards the top on the right side is a box title Resource Information that contains a listing, Requires Authentication?
if Requires Authenticaion has anything other than yes, you don't need to use OAuth and don't need to use tweetr. you can use the urlloader to load make those http requests.
if authentication is required, you have significant work to do. i found it easiest to use tweetr in that situation.
for all 3 levels, users will need to login to their Twitter account, at least, once.
hey kglad, thanks for your help. things are a little clearer now.
I had a look at the REST API Resources, and dug out the "POST statuses/update_with_media" which requires authentication. So I shall proceed with using tweetr's oAuth class.
I've chosen to make the authentication a PINless one, since I'm currently dealin with an iPhone app, and I do not wish to disturb the user with a browser opening up everytime whenever an authentication is needed.
I had a look through tweetr's pinless authentication tutorial and found this piece of code:
oauth = new OAuth();
oauth.consumerKey = "YOUR_CONSUMER_KEY";
oauth.consumerSecret = "YOUR_CONSUMER_SECRET";
oauth.callbackURL = "http://your.callback.url";
oauth.pinlessAuth = true;
var rect:Rectangle = new Rectangle(50,50, 780, 500);
htmlLoader = HTMLLoader.createRootWindow(true, null, true, rect);
oauth.htmlLoader = htmlLoader;
I'm guessing the above code goes into the constructor? Or into a private function itself where it'll be called when a button is pressed or something.
Another question is, what is a request URL? It seems like the default address (according to my application details in dev.twitter.com) is http://api.twitter.com/1/. But that doesn't seem right at all.
1 person found this helpful
Two main steps are needed to use requests that requires authentication. First, you must register your game with Twitter. Second, you must either implement the OAuth protocol or use a library like Tweetr that implements the protocol.
To use requests that require authentication (and those for which it is supported), you must first register your game with Twitter at https://dev.twitter.com/apps/new.
Fill out their form, agree with all those rules, prove you are a human being by filling out the Captcha form and click the Create your Twitter application button.
Copy your Consumer key and Consumer secret. You will need both to make authenticated requests on behalf of users. These numbers are used by Twitter to identify your game when a user gives your game permission to make requests on their behalf.
Click the Settings tab and add an icon or change your settings, if needed. In particular, note the Application Type settings. If you need more than read-access, tick the Read and Write or Read, Write and Access direct messages.
Click the Update this Twitter application's settings if you made any changes or additions.
You don't need to worry about the http requests because your requests are going to use the tweetr api. but
is an http request. if authentication weren't needed and there were no security issues, you could just use that url with an htmlloader. the loader's complete listener function would contain twitter's response.
I kinda wished it had been a URL instead of having to go through a whole bunch of oAuth stuffs. I've already registered my game with Twitter's dev site and tried using the tweetr library for oAuth. I've also managed to initiate the "getAuthorization" function. But the return seems a little odd. The returning result (when I trace the event) is:
I thought it would've been a longer answer with the access token after the "=". But anyways. I'll keep trying in cracking this nut till I get an answer. Any help is still welcome . and thanks again kglad! I have a feeling I'm getting closer to my answer.
I kinda figured out, instead of using oAuth, perhaps I can use basic Authentication. Since all I'm aiming for is a simple popup box takes the player's username and password and assisting them in posting a tweet on their twitter. That way instead of authenticating and posting with his name all the time, his/her friends can choose to logout and use their username and passwords to post their scores on their twitter as well.
*Edit: Scrap that, Twitter doesn't support Basic Authentication anymore, well.. back to oAuth... perhaps when a user clicks the "logout" button, it prompts tweetr to endSession();?* thoughts anyone?
Just an update on my current progress. so far I've got the oAuth working. It generates an oauth_token and brought me to the twitter permission site.
My current problems are:
1. Understanding how the oAuth mounts itself onto my app (sorry, I had to use that word 'mount'. pretty funny eh?).
2. I can't call any of the tweetr's api functions. (ex. using the tweetr.statusupdate will land me an error, failing to send tweet due to a stream Error #2032 URL: https://api.twitter.com/1/statuses/update.xml
3.Thou the oAuth succesfully generated an oauth token (I assume that's the access token), it doesn't seem to be able to read my username. thus when I trace oauth, it returns a username and userID as null.
4. Is tweetr outdated?
Hopefully I'll get over this... What seemed like the simplest part of the project just became the most ultimately horrifying part of it.
i think twitter made some change that caused tweetr to fail.
i recently encountered a security sandbox issue when using the tweetr swc for the web. i removed the the tweetr swc from the library path and used the tweetr source files and edited those to use a gateway php file that allowed my web-based swf to call a local php file and the php file handled the cross-domain twitter request and response.
but because you're using an air app, you shouldn't have a cross-domain problem testing your installed app. ie, don't test from within flash.
Oh, I've totally forgotten that tweetr's source code is on the web too. Blinded myself with using the swc.
Is the cross-domain.xml used to create a proxy for tweetr to connect into twitter? I did install some sort of php script into my webpage to act as a proxy (seeing that most tutorials requires that as a serviceHost).
But now that I know I can dig further into the oAuth class to find for fixes, I guess it's not the end yet (was about to give up since I've ruled out all posibilities to "Tweetr is outdated").
a cross-domain.xml needs to be on twitter which it there. but it restricts access to twitter domains. it used to allow cross-domain access but not any more so, that's not any help.
hmmmm... should I just give up with tweetr then? I thought tweetr was the best swc I could find since it bundles with a twitter.swc that deals with sending tweets instead of having to painstakingly type out your own code that creates the tweet call. I'm still a little unclear when you mentioned that I won't have to deal with cross-domain.xml problems since my app is on air mobile (iphone).
i used the tweetr source files for a web app.
for an installed app (like air for iOS), you shouldn't have cross-domain problems. are you testing on an iDevice (you should be) or a simulator on a laptop (where you will have cross-domain issues)?
Great news, it's working now!!!! The moment I saw "Are you testing on an iDevice or a simulator on a laptop", it hit me that I was doing everything wrong, creating oAuth for a web-based instead of mobile based when I thought I was doing it for mobile. Anyways. I managed to use tweetrMOBILE.swc and created a pinless oauth as well.
Thank you soo much for your help kglad! Cheers to you man!
glad to hear that!
(and, you're welcome.)
Hi - how is your twitter app working now - Is Tweetr still working for you ?
I gave up on Tweetr cuz it's causing a nuisance for me. So instead I went with milkmangames's GoViral social extension. Thou I had to pay 60 bucks for it, but it sure saved lots of time and coding wise, it's only 1 line for the twitter function to work, definitly worth it to get it!
Hi, thanks for the reply. I also got the go viral ANE, but it just allows you to tweet. It does not allow you to look at people's friends, lists, follow, unfollow etc.
Now that we need to authenticate those things in Twitter API v1.1 it would be great if we had an API similar to the Facebook as3 API.