mmoreram/spotify-api-bundle

为 Symphony2 项目提供简单的 Spotify API 接口

v1.1.0 2014-02-18 17:16 UTC

This package is auto-updated.

Last update: 2024-08-29 03:29:15 UTC


README

SensioLabsInsight Scrutinizer Quality Score Latest Stable Version Latest Unstable Version Dependency Status Total Downloads

此包只是 Spotify API 的包装,供所有 Symphony2 开发者使用。您可以在这里找到所有 API 规范

目录

  1. 安装/配置
  2. API 搜索
  3. API 查询
  4. 贡献

安装/配置

标签

  • 使用 1.0-dev 版本获取最新更新。等同于 dev-master
  • 使用最新稳定版本标签以保持稳定发布。

安装 SpotifyApiBundle

您需要在 composer.json 文件中添加 require 行

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.3.*",

    "mmoreram/spotify-api-bundle": "dev-master"
}

然后您需要使用 composer 更新您的项目依赖项

$ php composer.phar update

并在 appkernel.php 文件中注册该包

return array(
    // ...
    new Mmoreram\SpotifyApiBundle\SpotifyApiBundle(),
    // ...
);

API 搜索

您可以搜索一个简单的艺术家名称,获取艺术家数组,最多 100 个结果

$page = 1;

$artists = $this
    ->container
    ->get('spotify.api.search')
    ->findArtist('Hans Zimmer', $page);

您也可以搜索一个简单的艺术家名称,只获取第一个艺术家

$artists = $this
    ->container
    ->get('spotify.api.search')
    ->findFirstArtist('Hans Zimmer');

您可以搜索一个简单的专辑名称,获取专辑数组,最多 100 个结果

$page = 1;

$albums = $this
    ->container
    ->get('spotify.api.search')
    ->findAlbums("Pirate of the Caribbean, at world's end", $page);

您也可以搜索一个简单的艺术家名称,只获取第一个艺术家

$albums = $this
    ->container
    ->get('spotify.api.search')
    ->findFirstAlbum("Pirate of the Caribbean, at world's end");

您可以搜索一个简单的曲目名称,获取曲目数组,最多 100 个结果

$page = 1;

$tracks = $this
    ->container
    ->get('spotify.api.search')
    ->findTracks("I don't think now is the best time", $page);

您也可以搜索一个简单的艺术家名称,只获取第一个艺术家

$tracks = $this
    ->container
    ->get('spotify.api.search')
    ->findFirstTrack("I don't think now is the best time");

API 查询

给定一个艺术家代码,您可以使用 Spotify API 查询服务获取所有相关信息

$artist = $this
    ->container
    ->get('spotify.api.search')
    ->getArtist('spotify:artist:0YC192cP3KPCRWx8zr8MfZ');

给定一个专辑代码,您也可以获取所有相关信息

$album = $this
    ->container
    ->get('spotify.api.search')
    ->getAlbum('spotify:album:6JoI0NEAqeJ20X6lU3Drx0');

给定一个曲目代码,您也可以获取所有相关信息

$track = $this
    ->container
    ->get('spotify.api.search')
    ->getTrack('spotify:track:5sbwYsgzeg7wsug1A1pTiO');

贡献

所有代码都是按照 Symphony2 代码格式编写的,因此每个 pull request 必须通过 phpcs 标准验证。您应该阅读 Symfony2 编码标准 并安装 CodeSniffer 以验证所有代码。

此外,还有关于贡献此项目的政策。所有 pull request 必须逐步解释,以便我们更容易理解和合并。所有新功能都必须使用 PHPUnit 进行测试。

如果您想贡献,请阅读文档中的 贡献代码 部分。如果您正在提交 pull request,请遵循 提交补丁 部分的指南,并使用 Pull Request 模板

Bitdeli Badge