문제

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