使用python-twitter API v1.0获取{“errors”:[{“message”:“Bad Authentication data”,“code”:215}]}

时间:2013-06-13 08:54:58

标签: twitter twitter-oauth python-twitter

我正在使用python-twitter API v1.0。它说它适用于twitter API的v1.1。 这是我的代码:

import json
import urllib2
import urllib
import csv
file1 = open("somez.csv", "wb")
fname="tw1.txt"
file=open(fname,"r")
ins = open( "tw1.txt", "r" )
array = []
for line in ins:
   array.append( line )
   s = 'https://api.twitter.com/1.1/statuses/show/' + line[:-1] + '.json'
   print s
   try:

       data=urllib2.urlopen(s)
   except:
       print "Not Found"
    continue
   print data
   json_format=json.load(data)
   js=json_format
   print line[:-1]
   print js[('user')]['id']
   print  js[('user')]['created_at']
   print js['retweet_count']
   print js['text']
#   js = js.decode('utf-8')
   one = line[:-1].encode('utf-8')
   thr = js['user']['id']
   two = js['user']['created_at'].encode('utf-8')
   four = js['retweet_count']
   five = js['text'].encode('utf-8')
   rw =  [one,two,thr,four,five];
   spamWriter = csv.writer(file1 , delimiter=',')
   spamWriter.writerow(rw)
file1.close()

我无法检索任何数据。它说“找不到”。当我打开其中一个网址时,出现此错误:

{"errors":[{"message":"Bad Authentication data","code":215}]}

任何人都可以提出问题所在吗?

0 个答案:

没有答案