Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

The easiest way to handle Twitter authentication in your Titanium Mobile app

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .settings
Octocat-spinner-32 Resources
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .project
Octocat-spinner-32 README.md
Octocat-spinner-32 manifest
Octocat-spinner-32 tiapp.xml
README.md

twitter-titanium

twitter-titanium is a client-side Twitter library for Titanium Mobile. It simplifies the task of authenticating a user via Twitter. A backend is not required. It's designed to emulate the API of the Facebook module included in Titanium Mobile.

It presents a very simple and straightforward API. You provide your OAuth configuration and simply call authorize(). The user is prompted with a modal WebView to login to Twitter. After the user has logged in, the WebView disappears and a login event is fired. Requests to Twitter's API endpoints are done with the request() function. We intentionally are not wrapping Twitter's API calls, this can become a maintainence issue if Twitter updates it's API.

How to use

There is an example app included in this repository. See app.js.

var client = Twitter({
  consumerKey: "INSERT YOUR KEY HERE",
  consumerSecret: "INSERT YOUR SECRET HERE"
});

client.authorize(); // Pops up a modal WebView

client.addEventListener('login', function(e) {
  if (e.success) {
    // Your app code goes here... you'll likely want to save the access tokens passed in the event.

    // Here's an example API call:
    client.request("1/statuses/home_timeline.json", {count: 100}, 'GET', function(e) {
      if (e.success) {
        var data = JSON.parse(e.result.text);
      } else {
        alert(e.error);
      }
    });
  } else {
    alert(e.error);
  }
});

To use twitter-titanium in your app, download and copy the following files into your app: twitter.js jsOAuth-1.3.1.js

Nice features

  • Android compatible and tested!
  • On iOS, a back button is displayed if the user does any navigation within the WebView. For example, if the user clicks the forgot password link.

Thanks

  • twitter-titanium uses the jsOAuth library by @bytespider
  • Metamorph.js by @wycats and @tomdale for inspiration

Contact

twitter-titanium was written by Erik Bryn. You can find him on Twitter at @ebryn.

Something went wrong with that request. Please try again.