【问题标题】:soundcloud api python Get list of followers user idssoundcloud api python 获取关注者用户ID列表
【发布时间】:2016-03-25 05:48:09
【问题描述】:

使用 python 和 soundcloud api,我如何返回我的关注者列表;他们的用户名和ID? 我跑了

   followers = client.get('/me/followers')
   print followers
   for user in followers:
   print " "
   print user.id
   print user.username

但这只会返回

    soundcloud.resource.Resource object at NUMBER
    TypeError: 'Resource' object is not iterable

我尝试做的所有其他事情都很好,我使用用户名+密码登录方法进行身份验证并获取令牌...但是当我尝试查看关注者而不是应该是列表时,我仍然只返回一个资源资源 我可能使用了错误的 get 方法吗?

【问题讨论】:

    标签: python api soundcloud


    【解决方案1】:
    followers = client.get('me/followers').collection
    for user in followers:
        print(user.obj['username'],user.obj['id'])
    

    followers = client.get('me/followers').obj["collection"]
    for user in followers:
        print(user['username'],user['id'])
    

    【讨论】:

      【解决方案2】:

      我不在家,但请尝试 user['id']。

      编辑:抱歉,错误不存在。

      好吧,这是一种使用未记录的 api 的方法,但会很好:

      followers = client.get('me/followers.json')
      for user in followers:
          print(user.username,user.id)
      

      【讨论】:

      • 我仍然收到“TypeError: 'Resource' object is not iterable”错误,尽管资源编号不同。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-20
      • 2017-04-20
      • 2017-09-23
      • 2019-02-26
      • 1970-01-01
      • 1970-01-01
      • 2021-02-27
      相关资源
      最近更新 更多