1

我正在使用 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()

我无法检索任何数据。它说“未找到”。当我打开其中一个 URL 时,我收到此错误:

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

谁能提出问题可能是什么?

4

0 回答 0