Reputation: 91
Using python and the soundcloud api, how can I return a list of my followers; their usernames and ids? I run
followers = client.get('/me/followers')
print followers
for user in followers:
print " "
print user.id
print user.username
But that only returns
soundcloud.resource.Resource object at NUMBER
TypeError: 'Resource' object is not iterable
Everything else I try to do works fine, I authenticate and get a token using the username + password login method... But I still only get one resource returned when i try to view followers as opposed to what should be a list of resources Am i perhaps using the wrong get method?
Upvotes: 2
Views: 604
Reputation: 341
followers = client.get('me/followers').collection
for user in followers:
print(user.obj['username'],user.obj['id'])
or
followers = client.get('me/followers').obj["collection"]
for user in followers:
print(user['username'],user['id'])
Upvotes: 1
Reputation: 9
I'm away from home but try user['id'].
Edit: oups sorry the error is not there.
Alright here's a way to do it that uses an undocumented api but would be just fine:
followers = client.get('me/followers.json')
for user in followers:
print(user.username,user.id)
Upvotes: 0