forked from uzbekjon/jTwitter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.jtwitter.js
65 lines (60 loc) · 1.59 KB
/
jquery.jtwitter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* jTwitter 1.1.2 - Twitter API abstraction plugin for jQuery
*
* Copyright (c) 2009 jQuery Howto
* Copyright (c) 2010 Electric Pulp
*
* Licensed under the GPL license:
* http://www.gnu.org/licenses/gpl.html
*
* URL:
* http://jquery-howto.blogspot.com
* http://electricpulp.com
*
* Author URL:
* http://jquery-howto.blogspot.com
* http://electricpulp.com
*
*/
(function( $ ){
$.extend( {
jTwitter: function( username, numPosts, fnk ) {
var info = {};
// If no arguments are sent or only username is set
if( username == 'undefined' || numPosts == 'undefined' ) {
return;
} else if( $.isFunction( numPosts ) ) {
// If only username and callback function is set
fnk = numPosts;
numPosts = 5;
}
var url = "http://twitter.com/status/user_timeline/"
+ username + ".json?count="+numPosts+"&callback=?";
$.getJSON( url, function( data ){
if( $.isFunction( fnk ) ) {
fnk.call( this, data );
}
});
}
});
$.extend( {
jTwitterSearch:function( query, numPosts, fnk) {
var info = {};
// If no arguments are sent or only username is set
if( query == 'undefined' || numPosts == 'undefined' ) {
return;
} else if( $.isFunction( numPosts ) ) {
// If only username and callback function is set
fnk = numPosts;
numPosts = 5;
}
if (!query.match(/^q=/)) query = 'q='+query;
var url = "http://search.twitter.com/search.json?&"+query+"&rpp="+numPosts+"&callback=?";
$.getJSON( url, function( data ){
if( $.isFunction( fnk ) ) {
fnk.call( this, data );
}
});
}
});
})( jQuery );