atomescrochus/laravel-musixmatch

此包已被废弃,不再维护。未建议替换包。

支持缓存的Musixmatch API搜索

0.2.1 2017-10-09 19:58 UTC

This package is auto-updated.

Last update: 2020-04-07 18:55:21 UTC


README

Latest Stable Version License Total Downloads

atomescrochus/laravel-musixmatch包为从任何Laravel >= 5.3应用中搜索Musixmatch API提供了一种简单的方法。

此包不能在生产环境中使用,仍然被视为一个正在进行的工程(欢迎贡献!)。它需要PHP >= 7.0

安装

您可以通过composer安装此包

$ composer require atomescrochus/laravel-musixmatch

然后您需要安装包的服务提供者,除非您正在运行Laravel >=5.5(它将使用包自动发现)

// config/app.php
'providers' => [
    ...
    Atomescrochus\Musixmatch\MusixmatchServiceProvider::class,
];

如果您想更改默认值,您还必须发布配置文件

php artisan vendor:publish --provider="Atomescrochus\Musixmatch\MusixmatchServiceProvider" --tag="config"

您还需要在.env文件中放置您可以从Gracenote开发者账户获取的值

MUSIXMATCH_APIKEY=12345678

使用

// here is an example query to search Musixmatch API
$search = new \Atomescrochus\Musixmatch\Musixmatch();
$results = $search->trackSearch('poker face', 'lady gaga')->results();

// or if you already have the track id and wants the lyrics
$lyrics = new \Atomescrochus\Musixmatch\Musixmatch();
$results = $lyrics->getLyrics(15476784)->results();

// you can change the default cache duration (of one day) like so
$lyrics->setCacheDuration(60); // in minutes

// If you ever find yourself that you want to check your local cache for a result, without actually polling the API:
$results = $lyrics->cacheOnly()->getLyrics(15476784)->results();

// In case you only want to check if the query exists in the cache, without actually pulling the data:
$existInCache = $lyrics->inCache()->getLyrics(15476784)->results(); // returns boolean

结果

在上面的示例中,$results返回的对象包含:结果集合;结果的计数值;原始响应数据;缓存信息,以及发送到API的未格式化查询。

测试

这基本上是API的一个包装器。我们假设Musixmatch API已经被测试,我们不会进行重复测试。

变更日志

请参阅CHANGELOG以获取有关最近更改的更多信息。

贡献

请参阅CONTRIBUTINGCONDUCT以获取详细信息。

安全

如果您发现任何与安全相关的问题,请通过jp@atomescroch.us发送电子邮件,而不是使用问题跟踪器。

鸣谢

许可

MIT许可证(MIT)。请参阅许可文件以获取更多信息。