Git Product home page Git Product logo

twitter-for-as3's Introduction

Twitter for AS3

ActionScript 3 library for Twitter API v1.1

This is an unofficial project. Don't ask your question to the Twitter official.

Requirements

Usage

First steps

If you are not used to dealing with Twitter authentication and APIs, it may help you reading the documentation of Twitter.

Get the consumer key and the consumer secret for your application.

Please login to https://dev.twitter.com/ with your twitter account and create or select your application. You can get the keys from "Keys and Access Tokens" tab of the your app's page.

Create an instance of Twitter class.

If you already have access tokens, please go to 6.

Specify your keys to its arguments.

var twitter:Twitter = new Twitter(<your consumer key>, <your consumer secret>);

Get the request token and the request token secret.

First, send a request by twitter.oauth_requestToken()

var rtRequest:TwitterRequest = twitter.oauth_requestToken();

and add an event listener for TwitterRequestEvent.COMPLETE to rtRequest.

rtRequest.addEventListener(TwitterRequestEvent.COMPLETE, <listener>);

As the request is complete, you can get the URL to authenticate the app on your account by

twitter.getOAuthAuthorizeURL();

and open the URL in your browser.

After authentication you get a PIN, that is used in the next step.

Get the access token and the access token secret.

Let pin be the PIN you've get, send a request by twitter.oauth_accessToken()

var atRequest:TwitterRequest = twitter.oauth_accessToken(pin);

and also add an event listener for TwitterRequestEvent.COMPLETE to atRequest.

atRequest.addEventListener(TwitterRequestEvent.COMPLETE, <listener>);

If it's complete, you are ready to use the REST APIs.

For a test, try to post a tweet.

twitter.statuses_update("Hello!");

If you already have the access token and the access token secret, you can sepcify them when you create an Twitter instance.

var twitter:Twitter = new Twitter(<consumer key>, <consumer secret>, <access token>, <access token secret>);

Then you can use the REST APIs immediately.

Error handling

To handle errors, add an event listener for TwitterErrorEvent to the request. This is an example for handling client errors (HTTP 4xx), and you can also handle server errors (HTTP 5xx) with TwitterErrorEvent.SERVER_ERROR in the same way.

var request:TwitterRequest = twitter.statuses_update(...);
request.addEventListener(TwitterErrorEvent.CLIENT_ERROR,
    function(event:TwitterErrorEvent):void
    {
        /* error handling code here */
        event.preventDefault();
    }
);

Example

An example app is in example directory.

License

The MIT License

Author

Susisu (Twitter, GitHub)

twitter-for-as3's People

Contributors

susisu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.