При этом используется REST API, а не Streaming API, но я думаю, что он сделает то, что вы ищете. Единственным ограничением является то, что API REST ограничивается последними 200 твитами, поэтому, если у вас было более 200 твитов за последнюю неделю, он будет отслеживать слова только из последних 200 твитов.
Обязательно замените имя пользователя в вызове API на желаемое имя пользователя.
<?php
//Get latest tweets from twitter in XML format. 200 is the maximum amount of tweets allowed by this function.
$tweets = simplexml_load_file('https://api.twitter.com/1/statuses/user_timeline.xml?include_entities=true&include_rts=true&screen_name=kimkardashian&count=2');
//Initiate our $words array
$words = array();
//For each tweet, check if it was created within the last week, if so separate the text into an array of words and merge that array with the $words array
foreach ($tweets as $tweet) {
if(strtotime($tweet->created_at) > strtotime('-1 week')) {
$words = array_merge($words, explode(' ', $tweet->text));
}
}
//Count values for each word
$word_counts = array_count_values($words);
//Sort array by values descending
arsort($word_counts);
foreach ($word_counts as $word => $count) {
//Do whatever you'd like with the words and counts here
}
?>