python2.6にtwitterのモジュールを入れる
http://pypi.python.org/pypi/python-twitter/0.5
> python setup.py install
{PYTHONHOME}/Lib/site-packages/twitter.py
以下2点に対処
diffの結果を以下に載せる。
--- twitter.log Wed Feb 18 21:53:39 2009 +++ twitter.py Wed Feb 18 22:05:47 2009 @@ -9,9 +9,9 @@ import base64 -import md5 +import hashlib import os -import simplejson +import json import sys import tempfile import time @@ -244,7 +244,7 @@ Returns: A JSON string representation of this twitter.Status instance ''' - return simplejson.dumps(self.AsDict(), sort_keys=True) + return json.dumps(self.AsDict(), sort_keys=True) def AsDict(self): '''A dict representation of this twitter.Status instance. @@ -502,7 +502,7 @@ Returns: A JSON string representation of this twitter.User instance ''' - return simplejson.dumps(self.AsDict(), sort_keys=True) + return json.dumps(self.AsDict(), sort_keys=True) def AsDict(self): '''A dict representation of this twitter.User instance. @@ -777,7 +777,7 @@ Returns: A JSON string representation of this twitter.DirectMessage instance ''' - return simplejson.dumps(self.AsDict(), sort_keys=True) + return json.dumps(self.AsDict(), sort_keys=True) def AsDict(self): '''A dict representation of this twitter.DirectMessage instance. @@ -920,8 +920,8 @@ if since_id: parameters['since_id'] = since_id url = 'http://twitter.com/statuses/public_timeline.json' - json = self._FetchUrl(url, parameters=parameters) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, parameters=parameters) + data = json.loads(jstr) return [Status.NewFromJsonDict(x) for x in data] def GetFriendsTimeline(self, user=None, since=None): @@ -950,8 +950,8 @@ parameters = {} if since: parameters['since'] = since - json = self._FetchUrl(url, parameters=parameters) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, parameters=parameters) + data = json.loads(jstr) return [Status.NewFromJsonDict(x) for x in data] def GetUserTimeline(self, user=None, count=None, since=None): @@ -987,8 +987,8 @@ raise TwitterError("User must be specified if API is not authenticated.") else: url = 'http://twitter.com/statuses/user_timeline.json' - json = self._FetchUrl(url, parameters=parameters) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, parameters=parameters) + data = json.loads(jstr) return [Status.NewFromJsonDict(x) for x in data] def GetStatus(self, id): @@ -1008,8 +1008,8 @@ except: raise TwitterError("id must be an integer") url = 'http://twitter.com/statuses/show/%s.json' % id - json = self._FetchUrl(url) - data = simplejson.loads(json) + jstr = self._FetchUrl(url) + data = json.loads(jstr) return Status.NewFromJsonDict(data) def DestroyStatus(self, id): @@ -1030,8 +1030,8 @@ except: raise TwitterError("id must be an integer") url = 'http://twitter.com/statuses/destroy/%s.json' % id - json = self._FetchUrl(url, post_data={}) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, post_data={}) + data = json.loads(jstr) return Status.NewFromJsonDict(data) def PostUpdate(self, text): @@ -1051,8 +1051,8 @@ raise TwitterError("Text must be less than or equal to 140 characters.") url = 'http://twitter.com/statuses/update.json' data = {'status': text} - json = self._FetchUrl(url, post_data=data) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, post_data=data) + data = json.loads(jstr) return Status.NewFromJsonDict(data) def GetReplies(self): @@ -1066,8 +1066,8 @@ url = 'http://twitter.com/statuses/replies.json' if not self._username: raise TwitterError("The twitter.Api instance must be authenticated.") - json = self._FetchUrl(url) - data = simplejson.loads(json) + jstr = self._FetchUrl(url) + data = json.loads(jstr) return [Status.NewFromJsonDict(x) for x in data] def GetFriends(self, user=None): @@ -1088,8 +1088,8 @@ url = 'http://twitter.com/statuses/friends/%s.json' % user else: url = 'http://twitter.com/statuses/friends.json' - json = self._FetchUrl(url) - data = simplejson.loads(json) + jstr = self._FetchUrl(url) + data = json.loads(jstr) return [User.NewFromJsonDict(x) for x in data] def GetFollowers(self): @@ -1103,8 +1103,8 @@ if not self._username: raise TwitterError("twitter.Api instance must be authenticated") url = 'http://twitter.com/statuses/followers.json' - json = self._FetchUrl(url) - data = simplejson.loads(json) + jstr = self._FetchUrl(url) + data = json.loads(jstr) return [User.NewFromJsonDict(x) for x in data] def GetFeatured(self): @@ -1116,8 +1116,8 @@ A sequence of twitter.User instances ''' url = 'http://twitter.com/statuses/featured.json' - json = self._FetchUrl(url) - data = simplejson.loads(json) + jstr = self._FetchUrl(url) + data = json.loads(jstr) return [User.NewFromJsonDict(x) for x in data] def GetUser(self, user): @@ -1132,8 +1132,8 @@ A twitter.User instance representing that user ''' url = 'http://twitter.com/users/show/%s.json' % user - json = self._FetchUrl(url) - data = simplejson.loads(json) + jstr = self._FetchUrl(url) + data = json.loads(jstr) return User.NewFromJsonDict(data) def GetDirectMessages(self, since=None): @@ -1155,8 +1155,8 @@ parameters = {} if since: parameters['since'] = since - json = self._FetchUrl(url, parameters=parameters) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, parameters=parameters) + data = json.loads(jstr) return [DirectMessage.NewFromJsonDict(x) for x in data] def PostDirectMessage(self, user, text): @@ -1175,8 +1175,8 @@ raise TwitterError("The twitter.Api instance must be authenticated.") url = 'http://twitter.com/direct_messages/new.json' data = {'text': text, 'user': user} - json = self._FetchUrl(url, post_data=data) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, post_data=data) + data = json.loads(jstr) return DirectMessage.NewFromJsonDict(data) def DestroyDirectMessage(self, id): @@ -1193,8 +1193,8 @@ A twitter.DirectMessage instance representing the message destroyed ''' url = 'http://twitter.com/direct_messages/destroy/%s.json' % id - json = self._FetchUrl(url, post_data={}) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, post_data={}) + data = json.loads(jstr) return DirectMessage.NewFromJsonDict(data) def CreateFriendship(self, user): @@ -1208,8 +1208,8 @@ A twitter.User instance representing the befriended user. ''' url = 'http://twitter.com/friendships/create/%s.json' % user - json = self._FetchUrl(url, post_data={}) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, post_data={}) + data = json.loads(jstr) return User.NewFromJsonDict(data) def DestroyFriendship(self, user): @@ -1223,8 +1223,8 @@ A twitter.User instance representing the discontinued friend. ''' url = 'http://twitter.com/friendships/destroy/%s.json' % user - json = self._FetchUrl(url, post_data={}) - data = simplejson.loads(json) + jstr = self._FetchUrl(url, post_data={}) + data = json.loads(jstr) return User.NewFromJsonDict(data) def SetCredentials(self, username, password): @@ -1515,7 +1515,7 @@ self._root_directory = root_directory def _GetPath(self,key): - hashed_key = md5.new(key).hexdigest() + hashed_key = hashlib.new("md5", key).hexdigest() return os.path.join(self._root_directory, self._GetPrefix(hashed_key), hashed_key)