Reputation: 41
I want to get the tweets by the people a user follows (i.e tweets on the user home page.) Is there any way to get them?
Upvotes: 2
Views: 8369
Reputation: 310832
Here's a basic solution that might help you get started:
<ul id="tweets">
<li>Loading tweets...</li>
</ul>
And in your JavaScript, assuming you have jQuery available:
var url = 'http://api.twitter.com/1/statuses/user_timeline.json?callback=?'
+ '&screen_name=yourusername&count=4';
$.getJSON(
url,
function (data)
{
var $tweets = $('#tweets');
$tweets.empty();
if (data.length !== 0) {
$.each(data, function (i, tweet)
{
if (tweet.text !== undefined) {
$tweets.append($('<li></li>', { text: tweet.text }));
}
});
} else {
$tweets.append($('<li></li>', { text: 'No recent tweets' }));
}
}
);
Upvotes: 4
Reputation: 1771
Do you mean something like this: http://jsfiddle.net/pborreli/pJgyu/?
It gets a number of tweets for a given user.
Upvotes: 4