I am working with the Java API of lastfm.

I want to extract all users from a group, say Belgium. How do I create a new group and extract their members?

Group mygroup = new Group();
PaginatedResult<de.umass.lastfm.User> users = mygroup.getMembers("Belgium", key);)

It gives me an error on the first line:

group() has private access.

This is a bit strange. How should I call the constructor and don't I have to pass the group name during construction?

Thanks for any insights!

有帮助吗?

解决方案

You are correct that the Group has a private constructor, and you cannot use it.

Looking at the source code the method called

 public static PaginatedResult<User> getMembers(String group, int page, String apiKey)

in de.umass.lastfm.Group lets you get all users, and it is static, so you can access it without creating a Group object first.

Do something like

PaginatedResult<de.umass.lastfm.User> users = Group.getMembers("Belgium", key);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top