2012-02-28 12 views
7

मैं ट्विटर की डेवलपर्स साइट पढ़ रहा हूं, लेकिन ऐसा करने के लिए आरईएसपी एपीआई में कोई विधि नहीं है, मुझे लगता है कि यह स्ट्रीमिंग एपीआई के साथ है, क्या कोई मुझे मार्गदर्शन कर सकता है कि यह कैसे करें ?, मुझे कुछ ऐसा ही चाहिए tweetstats, बस मुझे सबसे अधिक ट्वीट किए गए शब्द दिखाओ।मैं उन शब्दों को कैसे पुनर्प्राप्त करूं जिन्हें मैंने सबसे ज्यादा ट्वीट किया था?

+0

कृपया मदद करें !! एक संकेत, एक सलाह, जो भी – bentham

+0

इस प्रश्न के उत्तरों के आधार पर, ऐसा लगता है कि ट्विटर इतिहास को नहीं रखता है http://stackoverflow.com/questions/1662151/getting-historical-data-from-twitter –

+0

मुझे पता है कि इसलिए मैं एक सप्ताह के लिए जानना चाहता हूं – bentham

उत्तर

10

का जवाब दे यह बाकी एपीआई, नहीं स्ट्रीमिंग API का उपयोग करता है, लेकिन मुझे लगता है कि यह आप के लिए क्या देख रहे हो जाएगा के लिए

धन्यवाद। इस पर एकमात्र सीमा यह है कि यह आरईएसटी एपीआई द्वारा नवीनतम 200 ट्वीट्स तक सीमित है, इसलिए यदि पिछले सप्ताह में 200 से अधिक ट्वीट्स हैं तो यह केवल आपके हालिया 200 ट्वीट्स के शब्दों को ट्रैक करेगा।

अपने वांछित उपयोगकर्ता नाम के साथ एपीआई कॉल में उपयोगकर्ता नाम को प्रतिस्थापित करना सुनिश्चित करें।

<?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 
} 

?> 
+0

देखने का उत्तर देने के लिए धन्यवाद, अगर कोई बेहतर तरीका जानता है तो – bentham

+2

यदि आप बेहतर दिख रहे हैं, तो IMHO आपको "बेहतर" –

संबंधित मुद्दे

 संबंधित मुद्दे