调试Python Instagram API客户端“NoneType”没有len()

2024-03-28 22:52:29 发布

您现在位置:Python中文网/ 问答频道 /正文

这里是Python的新手,请忍受我。。。在

我尝试使用Python client for Instagram API,并在将令牌传递到InstagramAPI构造函数时输入有效的访问令牌和用户ID(是的,我运行代码时插入了我的访问令牌和用户ID,但忽略了发布问题):

from instagram.client import InstagramAPI

access_token = "YOUR_ACCESS_TOKEN"
api = InstagramAPI(access_token=access_token)
recent_media, next_ = api.user_recent_media(user_id="userid", count=10)
for media in recent_media:
   print media.caption.text

但在终端,我总是收到这样的错误:

^{pr2}$

关于如何调试这个错误有什么建议吗?具体来说,这个错误的可能来源是什么?在

TypeError: object of type 'NoneType' has no len()

Tags: 用户clienttokenapiidforaccess错误
1条回答
网友
1楼 · 发布于 2024-03-28 22:52:29

因为github上的doc(自述文件)不是最新的,所以您遇到了一个bug。仔细阅读这个问题,找到你的解决方案

Missing argument for InstagramAPI object instance

OAuth Signing is broken in 1.3.1

你的代码应该是:

from instagram.client import InstagramAPI 

access_token = "YOUR_ACCESS_TOKEN" 
client_secret = "YOUR_CLIENT_SECRET"
api = InstagramAPI(client_secret=client_secret, access_token=access_token) 

相关问题 更多 >