/** * @param string|array $channel # String is DEPRECATED scince v1.3 - Deliver Array * @param string $title * @param string $file * @param string|null $comment * @return Client\Response */ public function upload($channel, $title, $file, $comment = null) { if (!file_exists($file)) { return false; } if (!is_array($channel)) { @trigger_error('Channel as String is deprecated scince v1.3, please deliver an Array of Channels', E_USER_DEPRECATED); $channel = [$channel]; } $params = []; $params['title'] = $title; $params['initial_comment'] = $comment; $params['channels'] = implode(',', $channel); $params['content'] = file_get_contents($file); $params['fileType'] = mime_content_type($file); $params['filename'] = basename($file); return $this->client->send(Actions::ACTION_FILES_UPLOAD, $params); }
protected function authTest() { $authTest = $this->client->send(Client\Actions::ACTION_AUTH_TEST, [], null); if ($authTest->getStatus()) { $statusMessage = '<info>Ok - User: '******'user'] . '</info>'; } else { $statusMessage = '<error>' . $authTest->getError() . '</error>'; } return $statusMessage; }
/** * @param string $channel * @param string $title * @param string $file * @param string|null $comment * @return Client\Response */ public function upload($channel, $title, $file, $comment = null) { if (!file_exists($file)) { return false; } $params = []; $params['title'] = $title; $params['initial_comment'] = $comment; $params['channels'] = null; $channelDiscover = new Channels($this->client); $channelId = $channelDiscover->getId($channel); if (!empty($channelId)) { $params['channels'] = $channelId; } $params['content'] = file_get_contents($file); $params['fileType'] = mime_content_type($file); $params['filename'] = basename($file); return $this->client->send(Actions::ACTION_FILES_UPLOAD, $params); }
/** * @param string $channel * @param int $from * @param int $count * @return Message[] */ public function history($channel, $from = null, $count = 10) { $messages = $this->client->send(Client\Actions::ACTION_CHANNELS_HISTORY, ['channel' => $this->getId($channel), 'oldest' => is_null($from) ? time() : $from, 'count' => $count]); $repository = []; if (!empty($messages->getData()['messages'])) { $messages = $messages->getData()['messages']; foreach (array_reverse($messages) as $message) { $objMsg = new Message(); $objMsg->setId($message['ts']); $objMsg->setChannel($channel); $objMsg->setType(isset($message['subtype']) ? $message['subtype'] : $message['type']); $objMsg->setUserId(isset($message['user']) ? $message['user'] : null); $objMsg->setUsername(isset($message['username']) ? $message['username'] : null); $objMsg->setContent($message['test']); $repository[] = $objMsg; } } return $repository; }
/** * @return array */ public function getUsers() { return $this->client->send(Actions::ACTION_USERS_LIST)->getData(); }