We'll be creating two files: namely, twitter.js
and twitterUsers.js
. Place these in the www/models
directory.
Let's start with the twitter.js
file:
var TWITTER = TWITTER || {};
As always, we define our namespace, in this case, TWITTER
, as seen in the following code snippet:
TWITTER._baseURL = "http://api.twitter.com/1/"; TWITTER._searchBase = "http://search.twitter.com/";
We define two variables global to the TWITTER
namespace: namely, _baseURL
and _searchBase
. These two URLs point at Twitter's JSON API; the first is for API requests such as user lookups, user streams, and such, while the latter is only for searching. We define them here for two reasons: to make the URLs a little less nasty in the following code, and if Twitter should ever decide to have a different version of the API (and you want to change it), you can do so here.
Next, we define our first object, TwitterUser
:
TWITTER.TwitterUser = function ( theScreenName, completion ) { var...