2011-09-25 9 views
5

मैं ट्विटर 4j ट्विटरस्ट्रीम ऑब्जेक्ट के माध्यम से ट्विटर पर सभी ट्वीट्स प्राप्त करने का प्रयास कर रहा हूं। मुझे यकीन नहीं है कि मुझे सभी ट्वीट मिल रही हैं। देरी का परीक्षण करने के बाद स्ट्रीमिंग एपीआई ट्वीट लौटाता है, मैंने ट्विटर पर अपने खाते से एक ट्वीट पोस्ट किया। लेकिन मुझे लंबे समय के बाद भी यह ट्वीट नहीं मिला।ट्विटर 4j ट्विटरस्ट्रीम को सभी ट्वीट्स नहीं मिलते हैं

क्या twitter4j ट्विटर पर पोस्ट किए गए प्रत्येक ट्वीट को पकड़ता है या यह ट्वीट्स का एक अच्छा प्रतिशत खो देता है? या मैं यहाँ कुछ गलत कर रहा हूँ? यहाँ कोड है कि मैं ट्वीट्स प्राप्त करने के लिए उपयोग कर रहा हूँ है:

 StatusListener listener = new StatusListener(){ 
     int countTweets = 0; // Count to implement batch processing 

     public void onStatus(Status status) { 
      countTweets ++; 
      StatusDto statusDto = new StatusDto(status); 
      session.saveOrUpdate(statusDto); 

      // Save 1 round of tweets to the database 
      if (countTweets == BATCH_SIZE) { 
       countTweets = 0; 
       session.flush(); 
       session.clear(); 
      } 
     } 

     public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {} 

     public void onTrackLimitationNotice(int numberOfLimitedStatuses) {} 

     public void onException(Exception ex) { 
      ex.printStackTrace(); 
     } 

     public void onScrubGeo(long arg0, long arg1) { 
      // TODO Auto-generated method stub 
     }   
    }; 

    ConfigurationBuilder cb = new ConfigurationBuilder(); 
    cb.setDebugEnabled(true) 
     .setOAuthConsumerKey(Twitter4jProperties.CONSUMER_KEY) 
     .setOAuthConsumerSecret(Twitter4jProperties.CONSUMER_SECRET) 
     .setOAuthAccessToken(Twitter4jProperties.ACCESS_TOKEN) 
     .setOAuthAccessTokenSecret(Twitter4jProperties.ACCESS_TOKEN_SECRET); 

    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance(); 
    twitterStream.addListener(listener); 

    session = HibernateUtil.getSessionFactory().getCurrentSession(); 
    transaction = session.beginTransaction(); 

    // sample() method internally creates a thread which manipulates TwitterStream and calls these adequate listener methods continuously. 
    twitterStream.sample(); 

उत्तर

10

मैं इस पर विरोधाभास के लिए खुला है, लेकिन मेरा मानना ​​है कि यह इस तरह काम करता है ...

स्ट्रीमिंग केवल API का एक नमूना देता है गैर-भागीदारों के लिए ट्वीट्स। यह "फायरहोज" के विपरीत "बाग़ नली" है जो कुछ ट्विटर भागीदारों को मिलता है। लेकिन आप पूर्ण पहुंच के लिए आवेदन कर सकते हैं।

। नमूना() यह "बाग़ नली" देता है। आपके ट्विटर खाते में फ़ायरहोज तक पहुंच नहीं होगी, हालांकि मुझे लगता है कि अगर आपके पास पहुंच है तो फ़ायरहोज के लिए ट्विटर है।

विनिर्देशों के लिए इस पृष्ठ पर "स्थिति/नमूना" के लिए खोजें: https://dev.twitter.com/docs/streaming-api/methods

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