Code Monkey home page Code Monkey logo

twstreamer's Introduction

+------------+
| twStreamer |
+------------+

Because we don't (yet) support Web Sockets on the Twitter Streaming API
(http://apiwiki.twitter.com/Streaming-API-Documentation), the only method
available to connect to the Streaming API from Javascript is to rely on a
Flash intermediary. This library provides a very small SWF (2K when compiled),
that will connect to the Streaming API and then call back out to JavaScript
with the JSON status object once it is received.

This library is only, currently, suitable for proof of concept scenarios.

+-----------------+
| Getting Started |
+-----------------+

This library depends on both jQuery 1.4.2 (http://jquery.com/) and jQuery SWF
Object (http://jquery.thewikies.com/swfobject/). With those, the twstreamer.js
and TwStreamFlash.swf files in the same directory, and the JS scripts included
via script tags, it is as simple as

    // set up the connection
    jQuery.twstreamer
      .init()
      .credentials(USERNAME, PASSWORD)
      .connect(
        function(tweet) {         // callback function
          // receive tweet
          console.log(tweet);
        },
        'track',                  // api method (track, follow, etc.)
        'twitter',                // api query
        'betastream.twitter.com'  // the host to connect to (optional)
      );

    // good housekeeping, once the connection can be closed
    jQuery.twstreamer.disconnect();

At this time, the Streaming API still uses basic auth, so the call to

    credentials(USERNAME, PASSWORD)

requires basic auth credentials to connect. Once the credentials have
been supplied

    connect(handler, method, query, host)

will actually initiate the connect and begin to proxy Tweets. The "handler"
needs to take a single jQuery parsed JSON object as an argument -- that is the
actual Tweet.

The host to connect to is optional, but at this time, stream.twitter.com, the
default Streaming API endpoint, does not serve a crossdomain.xml file. Only
the betastream.twitter.com does.

+--------------+
| Contributors |
+--------------+

Raffi Krikorian <[email protected]>
Russell D'Sa <[email protected]>
Premasagar Rose <[email protected]>

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.