【问题标题】:Error "Unable to parse response, not valid JSON" when extracting media from an Instagram handle从 Instagram 句柄中提取媒体时出现错误“无法解析响应,JSON 无效”
【发布时间】:2016-03-02 13:02:50
【问题描述】:

我正在使用 python-instagram 库来尝试提取 Instagram 用户发布的最后 10 个媒体。我正在使用user_recent_media 端点,如下所示:

from instagram.client import InstagramAPI
access_token = <my_access_token>

api = InstagramAPI(client_secret='XXXX', access_token=access_token[0])
usr = api.user_search('example_user')
userid = dir(usr[0]) 
allmed = api.user_recent_media(user_id=userid, count=10, min_id=0, max_id=10000000000000000000000000000000000)
print allmed

但是,我收到以下错误:

raise InstagramClientError('Unable to parse response, not valid JSON.', status_code=response['status'])
instagram.bind.InstagramClientError: (404) Unable to parse response, not valid JSON.

我的代码似乎有什么问题?

【问题讨论】:

标签: python python-2.7 api instagram instagram-api


【解决方案1】:

您应该将用户Twitter ID 传递为user_id(不是用户名/句柄名称/屏幕名称),使用user.id 访问它。

usr = api.user_search('example_user')
api.user_recent_media(user_id=usr[0].id)

我不知道你为什么要将dir(usr[0]) 传递为user_id

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多