ngsoft / emby-client-php
Emby.SDK的PHP版本。
1.1.2
2023-12-22 21:59 UTC
Requires
- php: >=8.1
- ext-mbstring: *
- ngsoft/tools: ^3.1|^4
- psr/cache: ^2.0|^3.0
- psr/http-client: ^1.0
- psr/log: ^1|^2|^3
- tuupola/http-factory: ^1.4
Requires (Dev)
- brick/varexporter: ^0.4.0
- friendsofphp/php-cs-fixer: ^3.34
- guzzlehttp/guzzle: ^7.8
- symfony/cache: ^6.3
- symfony/var-dumper: ^6.3
Suggests
- guzzlehttp/guzzle: Guzzle is a PHP HTTP client library
- symfony/cache: Provides extended PSR-6, PSR-16 (and tags) implementations
README
这是一个为Emby.SDK的PHP端口,用于Emby媒体服务器。使用它,您可以连接到您的Emby媒体服务器并管理它。
如何安装
您可以在项目内部使用composer安装此包
composer require ngsoft/emby-client-php
此库需要使用PSR-18 Http客户端,并使用Guzzle进行开发
如果您想使用guzzle
composer require guzzlehttp/guzzle
此库还支持任何PSR-6缓存(以保持您的EmbyConnect连接令牌)。
您可以使用以下方式安装缓存库
composer require symfony/cache
如何使用
您可以像这样初始化库
<?php use EmbyClient\Connection; use EmbyClient\EmbyConnect; use EmbyClient\Cache; use EmbyClient\HttpClient; // if you are using a custom cache library you can add that line // if you installed symfony/cache you don't need that line Cache::setCachePool($myCacheItemPoolInstance); // if you are using a custom Http Client you can add that line // with guzzle it is automatic HttpClient::setHttpClient($myHttpClientInstance); // To make a connection using emby connect: $connection = EmbyConnect::connect('usernameOrEmail', 'password', 'serverName'); // or to make a connection to a local or remote server using its ip or address using an api key // you can generate an api key for your server in the web interface of your emby server: // settings -> Advanced -> Api Keys -> New Api Key $connection = Connection::getConnection('ipAddressOrHostname', 'api_key'); // or with custom port $connection = Connection::getConnection('ipAddressOrHostname:port', 'api_key'); // you can also connect to a server using its http(s) address and port $connection = Connection::getConnection('https://example.com:8096', 'api_key'); // you can also test if a connection is authenticated if($connection->testConnection()) { // you can also make a connection active globally // the first to connect is automatically registered $connection->makeActive(); }
要执行API调用,您可以使用emby api客户端
use EmbyClient\ApiClient; $devices = ApiClient::getDevices();
您还可以直接使用服务
use EmbyClient\Model\Services\DeviceService; $service = new DeviceService($connection) $devices = $service->getDevices();
信息
所有位于'lib/'和ApiClient
中的模型都是使用src/generator.php
和位于resources/openapi_v3.json
中的emby模式生成的。
PHP-CS-Fixer已用于使其符合PSR-12。还使用了phan来检查错误