How do I get the words I tweeted the most?

I read the twitter developers site, but there is no method in the RESP API for this, I think that with Streaming Api, can anyone help me how to do this? I need something similar on a tweet, just show me the most tweet words.

thanks for the answer

+7
source share
1 answer

This uses the REST API, not the Streaming API, but I think it will do what you are looking for. The only restriction on this is that it is limited by the REST API to the last 200 tweets, so if you have more than 200 tweets last week, it will only track words from your last 200 tweets.

Be sure to replace the username in the API call with the username you need.

<?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 } ?> 
+10
source

All Articles