7

ツイッターで人をフォローするスクリプトを書こうとしています。tweepy API はかなり良さそうに見えますが、ユーザーの ID からスクリーン名へのマッピングに関連するいくつかの非直感的な動作に遭遇しています。

In [1]: import tweepy
In [2]: api = tweepy.API()

# get an arbitrary tweet
In [3]: tweet = api.search("anything")[0]

In [5]: tweet.text
Out[5]: 'Currently mourning the [potential] loss of around 500 pictures I took while in Oklahoma. Anyone know anything about Canon Rebels?'

# who tweeted it?
In [6]: tweet.from_user
Out[6]: 'helloregan'

# get the tweeters id
In [7]: tweet.from_user_id
Out[7]: 101962792

# i'm paranoid. just want to make sure its right.
In [8]: helloregan = api.get_user(user_id=tweet.from_user_id)           

# yep, same id.
In [9]: helloregan.id
Out[9]: 101962792

# lets check to see if its the same screen name? no. different person.
In [10]: helloregan.screen_name
Out[10]: 'kikiiputh'

何を与える?

4

1 に答える 1

7

問題が tweepy ではないことがわかりました: http://code.google.com/p/twitter-api/issues/detail?id=214

同じ問題に遭遇した他の tweepy ユーザーの参照用に更新されました。

于 2010-07-15T15:54:54.050 に答える