chipslays/vk-music

一个简单封装的 VK 音乐 API。

1.0.1 2021-06-30 10:05 UTC

This package is auto-updated.

Last update: 2024-09-29 05:56:42 UTC


README

一个简单封装的 VK 音乐 API。

要使用此库,首先您需要获取一个令牌和用户代理。

更多详情请见 vodka2/vk-audio-token

安装

composer require chipslays/vk-music

使用

use Chipslays\VkMusic\Client;

$client = new Client('YOUR_TOKEN', 'YOUR_USERAGENT');

$response = $client->search('Justin Bieber - Baby');

print_r($response->toArray());

// Array
// (
//     [count] => 3693
//     [items] => Array
//         (
//            [0] => ...
//            [1] => ...
//            [2] => ...
//         )
// )

您可以使用点符号通过 chipslays/collection 获取值。

print_r($response->get('items.0.artist'));

方法

注意: 可选参数 $extra 是一个以 key => value 形式的参数数组。

search(string $q, int $count = 10, int $offset = 0, array $extra = []): Collection

$client->search('Justin Bieber - Baby');

getById(string|array $audios): Collection

$client->getById(['371745461_456289486', '-41489995_202246189']);

get($owner_id, int $count = 10, int $offset = 0, $extra = []): Collection

$client->get('371745461');

getPlaylists($owner_id, int $count = 10): Collection

$client->getPlaylists('371745461');

getRecommendations(int $count = 10): Collection

$client->getRecommendations();

getPopular(int $count = 10): Collection

$client->getPopular();

method(string $method, array $params): Collection

$client->method('audio.search', [
    'q' => 'Justin Bieber - Baby',
    'count' => '10',
]);

助手

您可以使用 vk_music 助手代替 Client 类。

$client = vk_music('YOUR_TOKEN', 'YOUR_USERAGENT');

待办事项

  • 编写测试 😴💤

许可证

MIT