/**
  * Get shouts for a user.
  *
  * @param user The username to fetch shouts for
  * @param page The page number to fetch
  * @param limit An integer used to limit the number of shouts returned per page or -1 for default
  * @param apiKey A Last.fm API key.
  * @return a page of <code>Shout</code>s
  */
 public static PaginatedResult<Shout> getShouts(String user, int page, int limit, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   params.put("user", user);
   MapUtilities.nullSafePut(params, "limit", limit);
   MapUtilities.nullSafePut(params, "page", page);
   Result result = Caller.getInstance().call("user.getShouts", apiKey, params);
   return ResponseBuilder.buildPaginatedResult(result, Shout.class);
 }
Beispiel #2
0
 public static PaginatedResult<Event> getEvents(
     String location, String distance, int page, int limit, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   params.put("page", String.valueOf(page));
   MapUtilities.nullSafePut(params, "location", location);
   MapUtilities.nullSafePut(params, "distance", distance);
   MapUtilities.nullSafePut(params, "limit", limit);
   Result result = Caller.getInstance().call("geo.getEvents", apiKey, params);
   return ResponseBuilder.buildPaginatedResult(result, Event.class);
 }
 public static Collection<Tag> getTopTags(String user, int limit, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   params.put("user", user);
   MapUtilities.nullSafePut(params, "limit", limit);
   Result result = Caller.getInstance().call("user.getTopTags", apiKey, params);
   return ResponseBuilder.buildCollection(result, Tag.class);
 }
Beispiel #4
0
 /**
  * Get a list of valid countries and {@link de.umass.lastfm.Geo.Metro}s for use in the other
  * webservices.
  *
  * @param country Optionally restrict the results to those Metros from a particular country, as
  *     defined by the ISO 3166-1 country names standard
  * @param apiKey A Last.fm API key
  * @return a List of {@link de.umass.lastfm.Geo.Metro}s
  */
 public static Collection<Metro> getMetros(String country, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   MapUtilities.nullSafePut(params, "country", country);
   Result result = Caller.getInstance().call("geo.getMetros", apiKey, params);
   if (!result.isSuccessful()) return Collections.emptyList();
   Collection<DomElement> children = result.getContentElement().getChildren("metro");
   Collection<Metro> metros = new ArrayList<Metro>(children.size());
   for (DomElement child : children) {
     metros.add(new Metro(child.getChildText("name"), child.getChildText("country")));
   }
   return metros;
 }