擅长:python、mysql、java
<p>这个问题被问到已经将近三年了,但作为参考,当你在谷歌上搜索这个问题时,它会成为热门话题。在</p>
<p>在这篇文章中,pythontwitter仍然是这样(即pythontwitter没有直接的方法来识别待处理的友谊或关注者请求)。在</p>
<p>也就是说,可以通过扩展API类来实现它。这里有一个例子:<a href="https://github.com/itemir/twitter_cli" rel="nofollow">https://github.com/itemir/twitter_cli</a></p>
<p>相关片段:</p>
<pre><code>class ExtendedApi(twitter.Api):
'''
Current version of python-twitter does not support retrieving pending
Friends and Followers. This extension adds support for those.
'''
def GetPendingFriendIDs(self):
url = '%s/friendships/outgoing.json' % self.base_url
resp = self._RequestUrl(url, 'GET')
data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))
return data.get('ids',[])
def GetPendingFollowerIDs(self):
url = '%s/friendships/incoming.json' % self.base_url
resp = self._RequestUrl(url, 'GET')
data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))
return data.get('ids',[])
</code></pre>