java - 在java eclipse中调整last.fm api的页面或限制

标签 java eclipse last.fm

我是学生 我在 java eclipse 中使用当前的 last.fm Developer api。 但在使用过程中却出现了问题。 我想要大量的元数据值。 但结果只有50件。 我知道默认值是50。 所以,我调整了Page或limit,但结果仍然显示50件。

什么是理由?

public static void main(String[] args) {

    String key="#########";
    String tag = "ballad";
    int limit = 100;
    int page = 2;
    int i = 1;

    Chart<Artist> I3 = Tag.getWeeklyArtistChart(tag, page, key);
    Iterable<Artist> tag3 = I3.getTopArtists(page, key);


    for (Artist artist : tag3) {
        System.out.println("["+i+"]"+""+artist.getName());
        i++;
    }
}

结果

[1]德雷克 [2]埃莉·古尔丁 。 。 。 。 [50]一个方向

最佳答案

是的,默认值为“50”并且始终为“50”,因为您甚至没有设置或使用每页的项目数限制。请参阅chart.getTopArtist(page, limit, api_key)

您需要在以下位置添加每页项目限制:

Iterable<Artist> tag3 = I3.getTopArtists(page, limit, key)

完整代码:

public static void main(String[] args) {

    String key="#########";
    String tag = "ballad";
    int limit = 100;
    int page = 2;
    int i = 1;

    Chart<Artist> I3 = Tag.getWeeklyArtistChart(tag, page, key); // You can also set the limit here. (optional)
    Iterable<Artist> tag3 = I3.getTopArtists(page, limit, key); // Try to add the limit here. (optional)(Default 50)


    for (Artist artist : tag3) {
        System.out.println("["+i+"]"+""+artist.getName());
        i++;
    }
}

关于java - 在java eclipse中调整last.fm api的页面或限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26795425/

相关文章:

Eclipse:构建并符合不同的 JRE 版本

java - Java动态Web项目中重定向到html

Eclipse Luna 4.4 : application product with GMF, e4、BIRT、batik 插件未验证

python - ElementTree findall() 返回空列表

javascript - 如何在 JavaScript 中使用 for 循环检索多个 JSON 对象

last.fm - 是否可以从last.fm API的信息中获取scrobbling

java - Tomcat 应用程序未启动

java - 内存分配的最佳技术 - 重用一个全局内存或分配许多本地缓冲区并让它被垃圾收集

java - 如何以编程方式创建 CardView

java.lang.RuntimeException : Error while encoding: java. lang.ArrayIndexOutOfBoundsException:1