Reputation: 4399
I wanted to write a function for grabbing all tweets for specified user, but it returns only 20 most recent.
I came up with something like that:
function getTweets($user) {
$page = file_get_contents("http://twitter.com/{$user}");
$from = strpos($page, "<ol id='timeline' class='statuses'>");
$to = strpos($page, "</ol>");
$length = $to - $from;
$page =substr($page, $from, $length);
echo $page;
}
getTweets('user_name');
Is there a way to get round that?
Upvotes: 1
Views: 7114
Reputation: 3258
They only return a maximum of 3200 tweets per user by calling GET statuses/user_timeline, for more info look here: https://dev.twitter.com/discussions/1157
Upvotes: 0
Reputation: 8785
Twitter has an API that you should be querying to retrieve data such as tweets. It is far more efficient than crawling the HTML.
The statuses/user_timeline API service returns a list of tweets from any non-protected user. Here's an example of this service, configured to retrieve tweets for the user FRKT_ (that's me). You can customize the data it returns in many ways, such as by appending the count
variable to the URL like so to specify how many tweets you'd like to retrieve.
You should use an XML parser such as SimpleXML
rather than miscellaneous string functions such as strpos
like you demonstrated to parse the data returned from the API.
Upvotes: 8
Reputation: 9661
Twitter Libraries has libs for php listed. If you can grab a single users all tweets or not I'm afraid I don't know but the libs should be a good starting point.
Upvotes: 0