主页时间线和用户时间线有什么不同,什么是屏幕名?

问题描述 投票:0回答:1

你好,我的朋友,我不明白这段代码中的get_user_timeline和get_home_timeline有什么不同,以及什么是screen_name应用?

from twython import Twython, TwythonError
import json
timeline=[]
# Requires Authentication as of Twitter API v1.1
twitter = Twython('-----------------------',
                  '-----------------------------',
                  '--------------------',
                  '--------------')


try:
    user_timeline = twitter.get_user_timeline(screen_name='ryanmcgrath')
    # user_timeline = twitter.get_home_timeline(screen_name='ryanmcgrath')

except TwythonError as e:
    print (e)



# print (user_timeline)
timeline.append(user_timeline)

with open('timeline_j.json', '+w') as file:
    json.dump(timeline, file)
python twitter timeline twython
1个回答
0
投票

用户时间线代表指定用户发布(或转发)的推文列表。

主页时间线代表的是用户在登录的情况下会看到的Tweet列表,也就是他们关注的人的Tweet。只有当你拥有该用户的访问令牌和秘密时,这个功能才会生效--你无法获得其他用户的主页时间线。

在这里,我想说的是,如果你有访问令牌和秘密,你就不能获得其他用户的主页时间线。screen_name 是Twitter的用户名。

© www.soinside.com 2019 - 2024. All rights reserved.