【问题标题】:Get latest Instagram user photos using python-instagram library使用 python-instagram 库获取最新的 Instagram 用户照片
【发布时间】:2014-10-09 00:41:23
【问题描述】:

我在我的应用程序中使用 python-instagram api 以便从我的 instagram 帐户中获取最近的照片。我正在使用以下方法但无法成功:

from instagram.client import InstagramAPI
api = InstagramAPI(client_id='MY_CLIENT_ID', client_secret='MY_CLIENT_SECRET')
recent_media= api.user_recent_media(my_user_id, 6, max_id)
for media in recent_media:
   print media.images['standard_resolution'].url
endfor

这里我不明白 max_id 参数是什么。我试过忽略max_id,但它不起作用。我曾尝试获得大众媒体,并且成功了:

popular_media = api.media_popular(count=6)

谁能给我一些想法?我是一名 PHP 程序员,在 python 中有点新。我所需要的只是 - 获取我最近的 instagram 照片(其中 6 张)并在网页中显示它们的网址,以便用户可以点击它们。我需要为此使用访问令牌吗?我希望不是。因为我还没有任何使用 python API 的经验。

【问题讨论】:

  • 我希望即使没有 max_id 也能正常工作。您可以查看documentation 以了解参数所代表的含义。
  • 没有 max_id 是不行的。如果我忽略它,我会收到无效的 json 错误。

标签: python instagram


【解决方案1】:
  1. 尝试先验证您的 api,可能是这种情况。否则,您不一定有权访问用户最近的媒体
  2. 确保在这种情况下使用命名参数。

    api.user_recent_media(user_id=user_id, count=10)

  3. Max_id 是可选的,它指定您希望查看具有较小 id 的照片。 (例如 res=5,4,3,2,1 with max_id = 3 res=3,2,1)

【讨论】:

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