TwitterLib.js
What is it?
Why?
http://github.com/remy/twitterlib
Examples
Features
Features

•Consistent interface & data
 structure
•Support for custom APIs
•Automatic paging
•Included utilities:
 •ify, r...
API
timeline   status
favs       search
list
<script src="twitterlib.js"></script>
<script src="twitterlib.js"></script>
<script>
var tweets = document.getElementById('tweets');
twitterlib.timeline('rem', ...
<script src="twitterlib.js"></script>
<script>
var tweets = document.getElementById('tweets');
twitterlib.timeline('rem', ...
<script src="twitterlib.js"></script>
<script>
var tweets = document.getElementById('tweets');
twitterlib.timeline('rem', ...
<script src="twitterlib.js"></script>
<script>
var tweets = document.getElementById('tweets');
twitterlib.timeline('rem', ...
<script src="twitterlib.js"></script>
<script>
var tweets = document.getElementById('tweets');
twitterlib.status('rem', fu...
<script src="twitterlib.js"></script>
<script>
var tweets = document.getElementById('tweets');
twitterlib.favs('rem', func...
<script src="twitterlib.js"></script>
<script>
var tweets = document.getElementById('tweets');
twitterlib.list('rem/local'...
<script src="twitterlib.js"></script>
<script>
var tweets = document.getElementById('tweets');
twitterlib.search('@rem', f...
Options
Options

       twitterlib.timeline('rem', fn);

twitterlib.timeline('rem', {/*options*/}, fn);
Options

 • page: 1
 • limit: 200
 • since_id: 1
 • filter: 'foo'
Options
   twitterlib.timeline(
      'rem',
      {
         since_id: 123,
         filter: 'foo'
      },
      fn
   );
Filter
Filter
 foo
Filter
 foo
 foo bar   (foo and bar)
Filter
 foo
 foo bar      (foo and bar)
 foo OR bar
Filter
 foo
 foo bar      (foo and bar)
 foo OR bar
 "foo bar"    (atomic string)
Filter
 foo
 foo bar      (foo and bar)
 foo OR bar
 "foo bar"    (atomic string)
 foo -bar     (foo, not bar)
Filter
 foo
 foo bar      (foo and bar)
 foo OR bar
 "foo bar"    (atomic string)
 foo -bar     (foo, not bar)
 from:rem f...
Filter
 foo
 foo bar      (foo and bar)
 foo OR bar
 "foo bar"    (atomic string)
 foo -bar     (foo, not bar)
 from:rem f...
Utilities
Utilities


.custom(name, url)
Utilities

twitterlib.custom('dm',
  '/tweets?page=%page%&type=dm');

twitterlib.dm(callback);
Utilities


.next()
Utilities

var html = [];
twitterlib.timeline('rem', {limit: 5}, function(tweets){
   for (var i = 0; i < tweets.length; i...
Utilities

var html = [];
twitterlib.timeline('rem', {limit: 5}, function(tweets){
  for (var i = 0; i < tweets.length; i+...
Utilities


.render(tweet)
Utilities


.ify.clean(text)
Utilities
List of Twitter developers in the @WiredUK photo: @nuxnix/uk-
twitterati #devnest: http://www.wired.co.uk/wired-...
Utilities


.time.relative(t)
Utilities
Fri Jan 08 15:44:49 +0000 2010




 20 minutes ago
Photos by Balakov




Enjoy.
@rem
http://j.mp/dnfeb
TwitterLib.js
TwitterLib.js
TwitterLib.js
TwitterLib.js
Upcoming SlideShare
Loading in...5
×

TwitterLib.js

3,564

Published on

A walk through of the features of TwitterLib.js - a library that helps standardise all the Twitter API calls and all the data coming back from Twitter, and includes a collection of utility methods to speed development up.

Published in: Technology
1 Comment
3 Likes
Statistics
Notes
No Downloads
Views
Total Views
3,564
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
16
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide

TwitterLib.js

  1. 1. TwitterLib.js
  2. 2. What is it?
  3. 3. Why?
  4. 4. http://github.com/remy/twitterlib
  5. 5. Examples
  6. 6. Features
  7. 7. Features •Consistent interface & data structure •Support for custom APIs •Automatic paging •Included utilities: •ify, render, time
  8. 8. API
  9. 9. timeline status favs search list
  10. 10. <script src="twitterlib.js"></script>
  11. 11. <script src="twitterlib.js"></script> <script> var tweets = document.getElementById('tweets'); twitterlib.timeline('rem', function (data) { }); </script>
  12. 12. <script src="twitterlib.js"></script> <script> var tweets = document.getElementById('tweets'); twitterlib.timeline('rem', function (data) { var html = []; for (var i = 0; i < data.length; i++) { html.push(data[i].text); } }); </script>
  13. 13. <script src="twitterlib.js"></script> <script> var tweets = document.getElementById('tweets'); twitterlib.timeline('rem', function (data) { var html = []; for (var i = 0; i < data.length; i++) { html.push(twitterlib.render(data[i])); } }); </script>
  14. 14. <script src="twitterlib.js"></script> <script> var tweets = document.getElementById('tweets'); twitterlib.timeline('rem', function (data) { var html = []; for (var i = 0; i < data.length; i++) { html.push(twitterlib.render(data[i])); } tweets.innerHTML = html.join(''); }); </script>
  15. 15. <script src="twitterlib.js"></script> <script> var tweets = document.getElementById('tweets'); twitterlib.status('rem', function (data) { var html = []; for (var i = 0; i < data.length; i++) { html.push(twitterlib.render(data[i])); } tweets.innerHTML = html.join(''); }); </script>
  16. 16. <script src="twitterlib.js"></script> <script> var tweets = document.getElementById('tweets'); twitterlib.favs('rem', function (data) { var html = []; for (var i = 0; i < data.length; i++) { html.push(twitterlib.render(data[i])); } tweets.innerHTML = html.join(''); }); </script>
  17. 17. <script src="twitterlib.js"></script> <script> var tweets = document.getElementById('tweets'); twitterlib.list('rem/local', function (data) { var html = []; for (var i = 0; i < data.length; i++) { html.push(twitterlib.render(data[i])); } tweets.innerHTML = html.join(''); }); </script>
  18. 18. <script src="twitterlib.js"></script> <script> var tweets = document.getElementById('tweets'); twitterlib.search('@rem', function (data) { var html = []; for (var i = 0; i < data.length; i++) { html.push(twitterlib.render(data[i])); } tweets.innerHTML = html.join(''); }); </script>
  19. 19. Options
  20. 20. Options twitterlib.timeline('rem', fn); twitterlib.timeline('rem', {/*options*/}, fn);
  21. 21. Options • page: 1 • limit: 200 • since_id: 1 • filter: 'foo'
  22. 22. Options twitterlib.timeline( 'rem', { since_id: 123, filter: 'foo' }, fn );
  23. 23. Filter
  24. 24. Filter foo
  25. 25. Filter foo foo bar (foo and bar)
  26. 26. Filter foo foo bar (foo and bar) foo OR bar
  27. 27. Filter foo foo bar (foo and bar) foo OR bar "foo bar" (atomic string)
  28. 28. Filter foo foo bar (foo and bar) foo OR bar "foo bar" (atomic string) foo -bar (foo, not bar)
  29. 29. Filter foo foo bar (foo and bar) foo OR bar "foo bar" (atomic string) foo -bar (foo, not bar) from:rem foo
  30. 30. Filter foo foo bar (foo and bar) foo OR bar "foo bar" (atomic string) foo -bar (foo, not bar) from:rem foo to:rem foo
  31. 31. Utilities
  32. 32. Utilities .custom(name, url)
  33. 33. Utilities twitterlib.custom('dm', '/tweets?page=%page%&type=dm'); twitterlib.dm(callback);
  34. 34. Utilities .next()
  35. 35. Utilities var html = []; twitterlib.timeline('rem', {limit: 5}, function(tweets){ for (var i = 0; i < tweets.length; i++) { html.push(this.render(tweets[i])); } })
  36. 36. Utilities var html = []; twitterlib.timeline('rem', {limit: 5}, function(tweets){ for (var i = 0; i < tweets.length; i++) { html.push(this.render(tweets[i])); } }).next();
  37. 37. Utilities .render(tweet)
  38. 38. Utilities .ify.clean(text)
  39. 39. Utilities List of Twitter developers in the @WiredUK photo: @nuxnix/uk- twitterati #devnest: http://www.wired.co.uk/wired-magazine/ archive/2009/12/start/wired%27s-guide-to-the-uk-twitterati.aspx List of Twitter developers in the @WiredUK photo: @nuxnix/uk-twitterati #devnest: http://www.wired.co.uk/w...
  40. 40. Utilities .time.relative(t)
  41. 41. Utilities Fri Jan 08 15:44:49 +0000 2010 20 minutes ago
  42. 42. Photos by Balakov Enjoy. @rem http://j.mp/dnfeb
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×