atomescrochus / laravel-gracenote
此包已被废弃,不再维护。未建议替代包。
Laravel 5.* 包,用于搜索 Gracenote Web API。
1.5.0
2019-10-05 11:45 UTC
Requires
- php: ~7.0
- illuminate/support: ~5.1|~5.2|~5.3|~5.4|~5.5
- nategood/httpful: ^0.2.20
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0
- squizlabs/php_codesniffer: ^2.3
README
atomescrochus/laravel-gracenote
包提供了一种简单的方法,用于从任何 Laravel 5.* 应用程序与 Gracenote Web API 进行交互。
此包可用于生产环境,但仍应被视为正在进行中的工作(欢迎贡献!)。它需要 PHP >= 7.0
。
安装
您可以通过 composer 安装此包
$ composer require atomescrochus/laravel-gracenote
然后您需要安装包的服务提供者和别名,除非您正在运行 Laravel >=5.5,那么包将自动发现自身
// config/app.php 'providers' => [ ... Atomescrochus\Gracenote\GracenoteServiceProvider::class, ]; 'aliases' => [ .... 'GracenoteAPI' => Atomescrochus\Gracenote\Facades\Gracenote::class, ];
如果您想更改默认值,您还必须发布配置文件
php artisan vendor:publish --provider="Atomescrochus\Gracenote\GracenoteServiceProvider" --tag="config"
您还必须在 .env 文件中放置您可以在您的 Gracenote 开发者账户中获取的值
GRACENOTE_CLIENT_ID=12345678
GRACENOTE_CLIENT_TAG=abcdefg12345678
GRACENOTE_USER_ID=wxyz-9876
注意:如果您没有您的 Gracenote 用户 ID,您可以通过设置 GRACENOTE_CLIENT_ID
和 GRACENOTE_CLIENT_TAG
值来获取它,然后运行 php artisan gracenote:user-id
。这将执行相应的 API 调用来获取您的用户 ID,以便您可以将其添加到您的 .env 文件中。
使用方法
use Atomescrochus\Gracenote\Facades\Gracenote as GracenoteAPI; // $results will be an object containing a collection of results and raw response data from Gracenote // here is an example query to search in the Gracenote database $results = GracenoteAPI::lang('eng') // natural language of metadata ->cache(120) // integer representing minutes to cache results for ->searchMode('single_best') // OPTIONAL. Can be 'single_best' or 'single_best_cover' ->searchType('track_title') //either 'track_title', 'album_title', or 'artist' ->query('Poker face') // the search query ->search(); // do some magic // if you happen to have a gracenote id, you can search for it in this fashion // you need not to set other options, it is all set by default to be sure the search by ID // won't fail on Gracenote's part. $results = GracenoteAPI::lang('eng') // natural language of metadata ->cache(120) // integer representing minutes to cache results for ->getTrackById('167695000-B4D3EE5FF9011CCFCF0296FF1D8E8131');
测试
提供了一些测试。我认为它没有像可能的那样全面,但它显示了预期的行为工作良好,假设 Gracenote API 正在响应。测试还考虑在 Laravel 中安装包时运行,而不是独立运行。如果有人想改进当前的测试,请这样做!
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG。
贡献
请参阅 CONTRIBUTING 和 CONDUCT 以获取详细信息。
安全
如果您发现任何安全相关的问题,请通过电子邮件 jp@atomescroch.us 而不是使用问题跟踪器。
致谢
许可
MIT 许可证(MIT)。有关更多信息,请参阅 许可文件。