2014-11-09 17 views
5

का उपयोग करते समय त्रुटि मैं नीचे प्रोग्राम चला रहा हूं। लेकिन मुझे नीचे त्रुटि संदेश मिल रहा है। 401 **** 401 **** (दोहरा रहता है)401 त्रुटि tweepy

कोड (कुछ मंच से मिला) मूल रूप से ट्विटर से कनेक्ट और ट्वीट में लाने के लिए कोशिश करता है। जब यह उबंटू टर्मिनल पर चला गया तो 401 त्रुटि संदेश दिखाई देता है।

import sys 
import json 
import pymongo 
import tweepy 
consumer_key="XX" ##all the keys and codes have to be strings 
consumer_secret="XX" 
access_token = "XX" 
access_token_secret = "XX" 
# This is the listener, resposible for receiving data 

class StdOutListener(tweepy.StreamListener): 

    def on_data(self, data): 

     # Twitter returns data in JSON format - we need to decode it first 

     decoded = json.loads(data) 



     # Also, we convert UTF-8 to ASCII ignoring all bad characters sent by users 

     print '@%s: %s' % (decoded['user']['screen_name'], decoded['text'].encode('ascii', 'ignore')) 

     print '' 

     return True 



    def on_error(self, status): 

     print status 



if __name__ == '__main__': 

    l = StdOutListener() 

    auth = tweepy.OAuthHandler(consumer_key, consumer_secret) 

    auth.set_access_token(access_token, access_token_secret) 



    print "Showing all new tweets for #programming:" 



    # There are different kinds of streams: public stream, user stream, multi-user streams 

    # In this example follow #programming tag 

    # For more details refer to https://dev.twitter.com/docs/streaming-apis 

    stream = tweepy.Stream(auth, l) 

    stream.filter(track=['programming']) 
+0

आप अपने सही उपभोक्ता/एक्सेस टोकन का उपयोग कर रहे हैं? न केवल "कुछ फोरम" या "एक्सएक्स" से हैं? – Luigi

+0

ट्विटर डेवलपर साइट –

उत्तर

5

इस तरह यह काम करता है .. !!!

  • ट्विटर वर्तमान समय का ट्रैक रखता है।
  • यदि प्रमाणीकरण के लिए एक एपीआई अनुरोध किसी सर्वर से आता है जो दावा करता है कि यह समय है जो ट्विटर समय के 15 मिनट के बाहर है, तो यह 401 त्रुटि के साथ विफल हो जाएगा।

बस अपनी घड़ी की घड़ी को विश्व घड़ी के अनुसार रीसेट करें या इसे इंटरनेट द्वारा नियंत्रित करने दें आपकी समस्या हल हो जाएगी।

शुभकामनाएँ .. !!!

+0

से उत्पन्न किए गए सही लोगों का उपयोग कर रहा हूं धन्यवाद ... i.will कोशिश करें ... :-) –

+0

हेलो मैं उबंटू 14.10 –

+0

पर यह कैसे कर सकता हूं सेटिंग्स पर जाएं और अपनी घड़ी को अनुसार सेट करें वैश्विक समय क्षेत्र। – mark922

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