Điều này sử dụng API REST, không phải API phát trực tuyến, nhưng tôi nghĩ nó sẽ làm những gì bạn đang tìm kiếm. Hạn chế duy nhất của nó là nó bị giới hạn bởi REST API đến 200 tweet mới nhất, vì vậy nếu bạn có hơn 200 tweet trong tuần trước thì nó sẽ chỉ theo dõi các từ trong 200 tweet gần đây nhất của bạn.
Đảm bảo thay thế tên người dùng trong cuộc gọi API bằng tên người dùng mong muốn của bạn.
<?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
}
?>
Nguồn
2012-03-03 00:14:13
help please, please !! một gợi ý, một lời khuyên, bất cứ điều gì – bentham
Dựa trên câu trả lời cho câu hỏi này, nó không giống như twitter giữ một lịch sử http://stackoverflow.com/questions/1662151/getting-historical-data-from-twitter –
Tôi biết rằng vì vậy tôi muốn biết trong một tuần – bentham