从Soundcloud获得超过50个成员

时间:2016-03-27 18:37:45

标签: python pagination soundcloud members

我正在尝试使用Python API获取SoundCloud组的所有成员。

到目前为止,我可以获得前50个,但提供上面提到的“linked_pa​​rtitioning = 1”参数似乎不会转移到下一组成员。

我的代码是:

# Login and authenticate
client = soundcloud.Client(client_id = clientId,
                           client_secret = clientSecret,
                           username = username,
                           password = password)

# print authenticated user's username
print client.get('/me').username

# Get members
count = 1
total = 0;

while count > 0 and total < max:
    members = client.get('/resolve', url=group_url, linked_partitioning=1)

    count = len(members)
    total += count

    # Debug Output
    print "Total: " + str(total) + ". Retrieved another " + str(count) + " members."
    print members[0].username

我一直在关注:https://developers.soundcloud.com/docs/api/guide#pagination但仍无法找到解决方案。

1 个答案:

答案 0 :(得分:0)

使用linked_pa​​rtioning和limit工作的PHP代码片段(最大值可以是200)。默认结果集大小为50。

我对所有端点使用限制,但尚未触及组,因此我无法验证它是否在那里工作。

$qryString = self::API_ENDPOINT . self::SEARCH_API_ARTISTS
. "/" . $userId ."/tracks?" . $this->getClientId(true);
$qryString .= "&limit=" . self::MAX_API_PAGE_SIZE;
$qryString .= "&linked_partitioning=1";
相关问题