As promised, i just updated my Tweetr AS3 Library. For those who do not know what Tweetr is – Tweetr is a simple to use AS3 Twitter API Library, including practically all twitter and twitter search API features and an URLShortener Class.
The new version sports the following improvements:
As always, let me know what you are going to create with it, or if you need any help and of course any type of critique is always welcome!
Hi
I’d love to use Tweetr in my Flash AS3 project. I am programming using the Flash CS3 IDE. I think I can decipher your Flex code well enough to make it work (my AS3 isn’t advanced). My problem is I cannot find the import classes in the downloads from your Google Code page for example I get compile errors when I try this, where are these classes?
import com.swfjunkie.tweetr.Tweetr;
import com.swfjunkie.tweetr.events.TweetEvent;
import com.swfjunkie.tweetr.data.objects.StatusData;
I would greatly appreciate your help, do you have a Flash IDE example?
Thanks
Dave
Heya Dave
You are correct, there is no download at the moment for the sources. You can however use the supplied SWC. I will post an example for pure actionscript projects later today and also the sources as a download. Hope that will help you out. If you end up using it, let me know what you built with it ;)
Have a nice day,
Sandro
Thanks Sandro! I did download the SWC, but I didn’t know what to do with it! I might be able to figure it out if you can explain what I should be doing with it, however it might just be easier to wait for your pure AS project. Really appreciate your help, finding an easy to use Twitter AS3 API is impossible, but hopefully yours will do the job nicely as it seems to! Thanks again.
I just updated the tweetr project and added a pure as3 example.. I also added the source files to the downloads.
As for adding SWC Files to your project. It depends on what IDE you are using since adding SWC’s to a project is different for pretty much all IDE’s.
Thanks for this Sandro. To be honest I am a little lost. Firstly on how to use the SWC within the Flash CS3 IDE, I have tried adding it to the application support > adobe > Flash CS3 > en > configuration > components folder in the file system but I don’t know what to do after that. Can you help?
well.. after that you would have to just do the imports. Since i’m using CS4 and dont’ have CS3 installed anymore i sadly can’t really tell you the steps on how to do it. But since the source files are available now you might want to use those. just unpack the com folder into the folder where your fla is going to be. and then do the imports as usual. That’s should work just fine.
-Sandro
HI Sandro. Thanks again for answering my questions. As I said my AS3 is rusty so if I explain exactly what I am doing maybe you can let me know where I am going wrong.
I have the Example and and tweeter.swc files in the same folder as my FLA. Within my FLA I set ‘Example’ as the document class and then publish preview. I then get the compile errors saying that StatusData and TweetEvent cannot be found.
When you mentioned source files in your previous post, what are you referring to, the SWC or the AS or something else? I cannot see a ‘com’ folder in any of your downloads. If I had that I think I’d know what to do, but as I haven’t I think I am getting confused. As always a really appreciate your help.
Thanks
Dave
Hi Sandro, ignore my previous post! I found your src files!
Now I have an FLA, the com folder and Example.as all in the same directory. My FLA has a document class of ‘Example’. When I run it I get one error of ‘Definition mx.events:IndexChangedEvents could not be found. Any ideas?
HI Sandro! I have managed to get this working. I am only using ‘getUserTimeline’ at the moment but will upload the website when live and notify you so you can see what I have done.
Here is the AS I have written, please can you tell me how to limit the number of statuses I display in the ‘getUserTimeline’ function as it doesn’t seem to be working at the moment:
[code]
import com.swfjunkie.tweetr.Tweetr;
import com.swfjunkie.tweetr.data.objects.StatusData;
import com.swfjunkie.tweetr.events.TweetEvent;
import com.swfjunkie.tweetr.utils.TweetUtil;
initTweetr();
// Tweetr
function initTweetr():void
{
tweetr = new Tweetr();
tweetr.serviceHost = "labs.swfjunkie.com/tweetr/proxy";
tweetr.addEventListener(TweetEvent.COMPLETE, handleTweetsLoaded);
tweetr.addEventListener(TweetEvent.FAILED, handleTweetsFail);
tweetr.getUserTimeLine("username", "password", null, 200, 0);
}
// Variables
var tweetr:Tweetr;
// Eventhandling
function handleTweetsLoaded(event:TweetEvent):void
{
var displayText:String = "";
for(var i:int = 0; i < event.responseArray.length; i++)
{
var statusData:StatusData = event.responseArray[i];
displayText = displayText + statusData.user.screenName + "\n";
displayText = displayText + statusData.text + "\n\n";
}
output.text = displayText;
}
function handleTweetsFail(event:TweetEvent):void
{
output.text = "Tweets failed!";
}
[/code]
heya dave, i took your code and corrected it and added some inline comments. Hope that works for you:
-Sandro
I’m getting this error -” 1172: Definition mx.events:IndexChangedEvent could not be found. ” when I run the modified code posted by Sandro. I’m using Flash CS4, com folder placed in the same folder as .fla, actionscript setting – AS3. Please help me fix this issue.
This is infact a bug in the Tweetr Library. I just saw that there is an import line in the Main Class File that is not supposed to be there. Stupid mistake :P
Until i release an update you can manually fix this if you have the sources by deleting line 18 in Tweetr.as (/com/swfjunkie/tweetr/Tweetr.as) that reads:
import mx.events.IndexChangedEvent;
Hope that helps for now :)
Sounds like great work Sandro. I’m new to this page.. Tell me do you have any examples posted on what you Tweetr can do? Does it offer access to all of Twitter’s functionality inside of a swf for example?
I’d like to do something simple to start – maybe just post the latest tweet from a specific user.
have to run – i’ll check back later. looking forward to where you’ll go with this!
-Tom
Hi Sandro,
First off; kudos to you. I like your library alot. Well documented, easy to work with. How cool is that?
I’m writing an AIR Twitter application, and running into an issue when I attempt to authenticate a user. In Tweetr, I go ahead and set the un / pw for the user, then to test their account information I kick of getReceivedDirectMessages. I’m expecting a fault event of some type if the user can’t be authenticated against the Twitter API. Instead, I get a network prompt from Twitter asking me for a username / password.
I was curious; have you seen this before? If so, do you have any suggestions / ideas on how to bypass this dialog prompt? Thank you in advance, and if you need any additional information, please let me know.
Best,
A.
awesome work but my one problem right now is using the last status method.
when i make a StatusData object and call
statusData.user.lastStatus; it always
returns a null value. any suggestions?
Hi, I’m glad I found your blog.
I’m having the same issue trying to link into my RSS feed from my Twitter account and having it asking for my username and password.
What I’ve done is use the HTTPService tag and copied the url of my Twitter account RSS feed into its url. I was wondering if you know have to declare a param or something so that it knows my un and pw.
Thanks for your time.
I believe I am having more or less same problem as Blake J and a couple other people. The API overall works outstanding, but I have a problem as soon as I try to use a method such as getFriendsTimeLine() that needs authentication….that fails always (TweetEvent.FAILED). Can’t get it to work for the life of me, in Flash CS4 IDE, out of IDE, with and without proxy. I’m stumped. Any ideas?
getPublicTimeLine() and other methods work great.
(I’m using the open-sourced classes themselves since for some reason could not install the SWC.)
Update to last comment:
TweetEvent.STATUS == 401
Authentication problem of some kind.
i figured out my status problem but i have another one. can you not have two tweetr objects if one uses authentication to get data? because I have made two objects and one gets a search and the other a public time line, but when i try to have an object get a public timeline and the other one gets my friendlist the object getting the public timeline always fails.
another thing you can’t use the showsingletweet method unless your authenticated which to use it, it doesn’t require.
Did more testing: methods requiring authentication (eg, getFriendsTimeLine) work fine from AIR, though they fail (for me, anyway) in straight-up Flash.
I believe this has to do with security update Adobe made with 9.0.115
http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403184
Kind of a big headache not only for this but for anything requiring an Authorization header.
Sandro, any future plans for authenticating via oauth?
Hi Sandro,
i tried your class with Flash CS4 IDE.
If i use your serviceHost it’s all right.
If i try with my serviceHost i read this error:
Error opening URL ‘http://burnedbrain.com/proxy/statuses/public_timeline.xml’
tks
I’m sorry it’s been so quite from my side up till now. I’ve been rather busy with a work related project.
For those of you who still have problems using the Library, could you please make a post over at the Tweetr Library GoogleGroup ? It will make it easier for me to help you guys out.
Here is the Link to the GoogleGroup:
http://groups.google.com/group/tweetr-as3-library
Thanks for using Tweetr and hope to talk to y’all soon
Hallo & THX first !
Just needed your Lib for a demo and had some problems with the Tweetr.php proxy and curl_setopt_array() function. Really no Idea why cause curl is enabled.. problem may be this helps:
private function curl_setopt_array2(&$ch, $curl_options) { foreach ($curl_options as $option => $value) { if (!curl_setopt($ch, $option, $value)) { return false; } } return true; } /** * Requests Basic Authentication */ private function requestCredentials()than change
to
Hi Sandro,
Hey this is a little awkward, but I have been making a Twitter client called “Tweetr” for the last 2 years since the beta of Adobe Air.
It is very confusing that your have called your AS3 public class library Tweetr and confuses my product as well, which is actually written in AS3 and Flex.
I do request that you do not use this name in the future and if you would be kind enough to change the name. I absolutely have no issue with an open source AS3 library but people will be thinking of open sourced Tweetr and its source code which is not the case.
Many regards, John Ballinger developer of Tweetr.
Warning!!!
If you are using AIR, don’t forget turn public var browserAuth to false in line 146 from Tweetr.as, just like this:
public var browserAuth:Boolean = false;
I spent 2 weeks to get it work with my AIR aplaication.
p.d: sorry for my english
CAN YOU PLEASE STOP USING MY SOFTWARE’S NAME FOR THIS PROJECT. I AM NOT GETTING PEOPLE EMAILING ME THINKING THIS IS AN OPEN SOURCE VERSION OF TWEETR.
AGAIN SEE COMMENT ABOVE. PLEASE RENAME THIS PROJECT.
MANY REGARDS, JOHN.
Hey Sandro great work. Two questions:
- Any plans to integrate an OAuth library (can’t really build a commercial-quality client with Basic Auth).
- I added the [Bindable] attribute above the class declaration of your UserData class to make the “warning can not bind to property [etc.] on com…UserData” warnings go away.
Hi, sandro
i would like to use this, but have no idea how to start..
any tutorial?
Hi there, Tweetr suffers from the twitpocalypse bug. This can be easily fixed by changing the ‘id’ property of the StatusData class from int type to Number.
Cheers, Martijn.
Great class man. I’m starting to work with it in a project.
There is an problem to fix in your Air example:
you’ve changed the “browserAuth” with “useAuthHeaders”, so a lot of people will get crazy (like me) trying to mind why the autentication dont work properly :D
Thanks for your work.
Can you please give an example of what needs to be edited with-in the proxy file (if anything) to use the getUserTimeline() method in a pure AS3 on the web swf. I’ve tried to edit your Example.as by changing getPublicTimeline() to get userTimeLine() and can’t get it to work. My .swf always displays the public timeline no matter what. Any help would be AWESOME! Thanks in advance
http://www.redsixmedia.net/tweetTest.html
I laughed reading the guy claiming the name.
Any idea as to how to over come the cross domain problem for building desktop client app using ur library?
Hi Sandro,
i’m getting this error when i try to place a tweet with the following code (wich should be right):
Any suggestions ?
/statuses/update.xml
This method requires a POST.
package {
import flash.display.*;
import flash.net.navigateToURL;
import com.swfjunkie.tweetr.Tweetr;
import com.swfjunkie.tweetr.events.TweetEvent;
import com.swfjunkie.tweetr.data.objects.StatusData;
public class Main extends MovieClip {
public function Main():void {
//create a new tweetr instance
var tweetr:Tweetr = new Tweetr();
// add your login credentials
tweetr.username=”thisIsNotAUserName”;
tweetr.password=”herecomesmypassword”;
// add some event listeners for when a request succeeds or fails
tweetr.addEventListener(TweetEvent.COMPLETE, handleResult);
tweetr.addEventListener(TweetEvent.FAILED, handleFail);
// now send your tweet
tweetr.sendTweet(“my test tweet”);
//tweetr.search(“pv3d”);
}
public function handleResult(event:TweetEvent):void {
trace(“s6!”);
}
public function handleFail(event:TweetEvent):void {
trace(“fail!”);
}
}
}
Hey Sando,
I’m building a visual tweeter client (that enables the user easily send pics/vids/swfs with his tweets). I’m basing my work on your great Tweenr lib (thanks!).
My problem- can’t get the paging (page parameter) work when requesting a friend timeline (nor the count parameter). It Always returns the first page. Any idea?
Thanks!
Jonathan
Hi Sandro,
it works just fine with Mozilla, but not with EI, Safary, Google Chrome and with Opera asks permition to send user data.. Can one do something about it? At least, that the tweerr events are registrated and got response: tweetr.addEventListener(TweetEvent.COMPLETE, handleTweetsLoaded);
tweetr.addEventListener(TweetEvent.FAILED, handleTweetsFail);
Thanks!
Tania
Hi sandro,
I am having trouble authenticating, the examples you have posted on Google Code doesnt work either.
If anyone has successfully implemented authentication in Flash IDE please help as i have been stuck for a week now.
btw thank you sandro for the open source!
I am new to swc files so how do I install the one I downloaded from your site?
I having issues using createFavorite, I keep getting this error “Error opening URL ‘http://twitter.com/favorites/create/’” It seems like it’s not appending the id number on the end of the link. Do you have a working example of this?
Hi Sandro
in the output I get
Error opening URL ‘http://https://api.twitter.com/1/statuses/user_timeline.xml?hash=dG91cmluZ19tb2JpbGlzOnRtcHc4MDY2′
So it seems to mix the http with an https… How can I solve this ?
Hi Sandro.
I forgot to import a certain library , which is why I got that error. Solved.
But still I can’t get any Tweet display in flash. So I have been checking the getUserTimeLine method and added some traces in it.
Code :
public function getUserTimeLine(id:String = null, since_id:String = null, since_date:String = null, max_id:Number = 0, page:Number = 0):void
{
…
trace (“request = ” , request);
urlLoader.load(url);
}
From the Flash Output I got :
request = /statuses/user_timeline.xml
I would assume that in the request sting the username should be concatenated …
Hi Guido
It would probably be easier if you would post your problem over at the google groups site at: http://groups.google.com/group/tweetr-as3-library/.
Thanks,
Sandro
[...] http://blog.swfjunkie.com/2009/03/updated-tweetr-as3-library/ เวบของเจ้าของ Tweetr ครับลองคุยกับเขาดู [...]
Hi, awesome library, very nice of you to make this open source. I am integrating this into an AIR app I have, tweetr.getUserTimeLine() works great but I can’t seem to get tweetr.search() working. Code is below, let me know if you have any ideas, thanks.
__________________________
package {
import flash.events.Event;
import flash.display.MovieClip;
import com.swfjunkie.tweetr.events.TweetEvent;
import com.swfjunkie.tweetr.utils.TweetUtil;
import com.swfjunkie.tweetr.data.objects.StatusData;
import com.swfjunkie.tweetr.data.objects.SearchResultData;
import com.swfjunkie.tweetr.Tweetr;
public class twitter extends MovieClip
{
public function twitter():void
{
// create a tweetr instance
tweetr = new Tweetr();
tweetr.useAuthHeaders = true;
// pass the username & password
tweetr.username = “my username”;
tweetr.password = “my password”;
// add some eventlisteners
tweetr.addEventListener(TweetEvent.COMPLETE, handleTweetsLoaded);
tweetr.addEventListener(TweetEvent.FAILED, handleTweetsFail);
say_button.addEventListener(MouseEvent.CLICK, Speak_Tweet_Event);
//tweetr.getUserTimeLine();
tweetr.search(“gadgets”);
}
private function handleTweetsLoaded(event:TweetEvent):void
{
// assign the latest response to a data object
var tweet:StatusData = event.responseArray[0] as StatusData;
text.text = “@”+tweet.user.screenName + tweet.text + ” ” + TweetUtil.returnTweetAge(tweet.createdAt);
}
private function handleTweetsFail(event:TweetEvent):void
{
trace (“Tweet Called Failed”);
}
}
}