python - Tweepy(Twitter)更改为exists_friendship->lookup_friendship(Python)

标签 python twitter tweepy

过去,您可以通过 Twitter API 使用 Tweepy 从 contains_friendship 获得 True False,但由于去年的更改,您现在必须使用 Lookup_friendships(我认为每 15 分钟有 15 个速率限制?).. .我将如何修改这个Python代码(曾经有效)以反射(reflect)这一点并利用新函数?

它适用于本地社区/社区应用程序,我只是希望它检查是否有人正在关注经过身份验证的用户。

user_id 是您想要检查他们是否关注您的人(已在脚本前面定义)...

00000000000 是你自己的 user_id/应用程序用户的 id...但是这个 Tweepy link似乎建议您只使用“self”?

    if api.exists_friendship(user_id, 00000000000):
        print 'YAY! Friend!'
    else:
        print 'Boooo!'

注意Tweepy 是 here

注意不用说,这是行不通的:

if api.lookup_friendships(user_id, 00000000000):

最佳答案

所以,事实证明,Tweepy 的正确请求如下:

user_id = '00000000000'
print api.show_friendship(target_id=user_id)

返回经过身份验证的用户和其他用户之间关系的 JSON,其中“followed_by”具有 True/False 值。

关于python - Tweepy(Twitter)更改为exists_friendship->lookup_friendship(Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28563359/

相关文章:

python - 如何显示所有包含这些字符的单词?

javascript - 无法分享包含引用和作者的推文(FCC 随机引用机)

node.js - 使用Twitter API和Node串流我自己的 protected 推文

python - 使用 Tweepy 将屏幕名称列表转换为用户 ID

python - 简单的非基于 Web 的错误跟踪器

python - 如何在 python 中迭代/操作类对象列表(分散网络模拟中的节点爬行)

python - 如何在 Linux 中将覆盖的 python2 恢复为 python3?

python - 使用 python 和 tweepy 的 twitter "friends"的完整列表

python - 使用 Tweepy 收听流媒体和搜索推文。如何停止以前的搜索并只收听新的流?

python - 如何缩小 Tweepy 中的搜索结果?