Search code examples
actionscript-3apache-flextwitterflash-builder

Twitter api authentication flex mobile flash builder


i'm making a mobile app in flash builder 4.6. The should show some tweets with specific hashtags. after a very long search i've finally found a document that helped me. I'm using this guide http://www.adobe.com/content/dam/Adobe/en/devnet/flex/articles/twitter-trends/build-first-mobile-flex-app.pdf But it uses the older version of the twitter API. Now it needs authorization. And I'm totaly new to flash builder so I don't get where I have to do this (in which file) or what I should type there...


Solution

  • We've solved it ,

    this is an example of how our source code looks like in which we authorize the api and get/show the tweets.

    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="TOUS ENSEMBLE"
        initialize="init()">
    
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <s:ArrayCollection id="tweets" />
        </fx:Declarations>
    
        <s:states>
            <s:State name="normal" />
            <s:State name="busy"/>
            <s:State name="networkError"/>
        </s:states>
    
    
        <s:List id="list" top="0" left="0" right="0" bottom="0" dataProvider=" {tweets}">
            <s:itemRenderer>
                <fx:Component>
                    <s:ItemRenderer>
                        <s:Image source="{data.user.profile_image_url}" left="0" verticalCenter="0" width="60" height="60"/>
                        <s:Label text="{data.text}" left="65" right="5" top="5" bottom="5"/>
                    </s:ItemRenderer>
                </fx:Component>
            </s:itemRenderer>
    
        </s:List>
        <s:BusyIndicator id="busy" verticalCenter="0" horizontalCenter="0" width="60" height="60" includeIn="busy"/>
        <s:Label id="networkError" verticalCenter="0" horizontalCenter="0" text="Network Error Occured" includeIn="networkError"/>
        <fx:Script>
            <![CDATA[
                import de.danielyan.twitterAppOnly.TwitterSocket;
                import de.danielyan.twitterAppOnly.TwitterSocketEvent;
    
                private var _twitter:TwitterSocket;
                private var searchTweetKeyword;
    
                public function init():void
                {
                    _twitter = new TwitterSocket('I9ItnPjy670SsLOBcas5pJHGY', 'GpuPGqrCfRm53LpayKOVtGjdOFZNY3mTycQHJc2vf3SAeXDqME');
    
                    // twitter socket uses two events: 
                    _twitter.addEventListener(TwitterSocket.EVENT_TWITTER_READY, onTwitterReady);
                    // * The Twitter Data event, when the twitter Request has finished
                    _twitter.addEventListener(TwitterSocket.EVENT_TWITTER_RESPONSE, onTwitterData);
                    // * Catch IO Errors! This happens when no network is available
                    _twitter.addEventListener(IOErrorEvent.IO_ERROR,onError);
                    currentState="busy";
                }
                public function onError(event:Event):void
                {
                    currentState="networkError";
                }
    
                public function onTwitterReady(event:Event):void
                {
                    _twitter.request("/1.1/search/tweets.json?q=#belgianreddevils");
                }
    
                public function onTwitterData(event:TwitterSocketEvent):void
                {
                        // this message is 
                     currentState="normal";
                    var tweetList =  new ArrayCollection(event.response.statuses as Array);
                    //tweets = new ArrayCollection(event.response.statuses as Array);
                    trace(tweetList[0].text);
                    tweets = tweetList;
    
    
                }
    
    
    
            ]]>
         </fx:Script>
    </s:View>
    

    we've used help from the pdf that I've included and this github documentation https://github.com/denisdanielyan/as3-Application-Only-Twitter