Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for ionCube Encoder)
- *
- * @ Version : 4.1.0.1
- * @ Author : DeZender
- * @ Release on : 29.08.2020
- * @ Official site : http://DeZender.Net
- *
- */
- class EmbyApiClient
- {
- private $serverAddress;
- private $username;
- private $password;
- private $headers = [];
- public $accessToken;
- public function __construct($serverAddress = '', $username = '', $pwd = '')
- {
- $this->serverAddress = $serverAddress;
- $this->username = $username;
- $this->password = $pwd;
- $this->accessToken = $this->getAccessToken();
- }
- public function setRequestHeaders()
- {
- if ($this->accessToken) {
- $this->headers['token'] = 'X-MediaBrowser-Token: ' . $this->accessToken;
- }
- $this->headers['type'] = 'Content-Type: application/json';
- $this->headers['auth'] = 'X-Emby-Authorization: MediaBrowser Client=Android, Device=Samsung Galaxy SIII, DeviceId=xxx, Version=1.0.0.0';
- }
- public function getAccessToken()
- {
- $token = '';
- $res = $this->authenticateUser($this->username, $this->password);
- if (isset($res['response']['AccessToken']) && !empty($res['response']['AccessToken'])) {
- $token = $res['response']['AccessToken'];
- }
- return $token;
- }
- public function getUrl($name, $params = [])
- {
- $this->url = $this->serverAddress . '/emby/';
- $this->url = $this->url . $name;
- if (!empty($params)) {
- $this->url = $this->url . '?' . implode('&', $params);
- }
- return $this->url;
- }
- public function createUser($name)
- {
- $this->params = ['url' => $this->getUrl('Users/New'), 'name' => $name];
- return $this->curlPostRequest($this->params);
- }
- public function setUserPassword($userid, $newpw, $currentpw = '')
- {
- if (empty($userid) || empty($newpw)) {
- return ['status' => 'error', 'message' => 'Required params are missing.'];
- }
- $url = 'Users/' . $userid . '/Password';
- $this->params = ['url' => $this->getUrl($url), 'CurrentPw' => $currentpw, 'NewPw' => $newpw];
- return $this->curlPostRequest($this->params);
- }
- public function deleteUser($userId)
- {
- if (empty($userId)) {
- return ['status' => 'error', 'message' => 'Userid is required.'];
- }
- $url = 'Users/' . $userId;
- $this->params = ['url' => $this->getUrl($url)];
- return $this->curlDeleteRequest($this->params);
- }
- public function updateUserPolicy($userId, $policies)
- {
- if (empty($userId)) {
- return ['status' => 'error', 'message' => 'Userid is required.'];
- }
- if (empty($policies)) {
- return ['status' => 'error', 'message' => 'Required params are empty.'];
- }
- $url = 'Users/' . $userId . '/Policy';
- $this->params = array_merge(['url' => $this->getUrl($url)], $policies);
- .....................................................................
- .............................................
- ...................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement