【问题标题】:Perform only search on a genre with web api spotify使用 web api spotify 仅对流派执行搜索
【发布时间】:2017-09-19 15:18:26
【问题描述】:

我有一个在 spotify 上执行搜索的脚本。 但是我想在我的网站上只显示一个流派,从而将搜索限制在一种流派中。例如:摇滚。

在搜索字段中输入任何乐队的名称时,如果它是摇滚类型,它将出现,否则什么都不会发生。

我将放置具有此支持的 spotify 链接:

https://developer.spotify.com/web-api/console/get-search-item/#complete

我要修改的代码是这样的:

<?php namespace App\Services\Search;

interface SearchInterface {

    /**
     * Search database using given params.
     *
     * @param string  $q
     * @param int     $limit
     * @param string  $type
     *
     * @return array
     */
    public function search($q, $limit = 10);
}

【问题讨论】:

    标签: php spotify


    【解决方案1】:

    来自https://developer.spotify.com/documentation/web-api/reference/#endpoint-search/

    其他可能的字段过滤器,取决于要搜索的对象类型,包括流派(适用于曲目和艺术家)、upc 和 isrc。例如,q=lil%20genre:%22southern%20hip%20hop%22&type=artist。如果流派关键字字符串包含空格,请在其周围使用双引号。

    当您提交搜索查询时,将genre:"your genre" 与您在查询中搜索的任何其他字词一起添加。

    【讨论】:

    • 所以在我的情况下会是这样吗? q = lil%20genre:%22rock%22
    • 我没有尝试过那个特定的例子,但看起来不错,它是一个搜索词和术语的列表(其中术语的格式为键:值),由转义空格分隔。
    猜你喜欢
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 2018-06-12
    • 1970-01-01
    • 2021-11-04
    • 2018-10-27
    • 2018-09-09
    • 1970-01-01
    相关资源
    最近更新 更多