uploadMedia example


        if (!$message instanceof ChatMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['text'] = $message->getSubject();
        $response = null;

        try {
            if (isset($options['attach'])) {
                $options['media']['media_ids'] = $this->uploadMedia($options['attach']);
                unset($options['attach']);
            }

            $response = $this->request('POST', '/2/tweets', ['json' => $options]);
            $statusCode = $response->getStatusCode();
            $result = $response->toArray(false);
        } catch (ExceptionInterface $e) {
            if (null !== $response) {
                throw new TransportException($e->getMessage()$response, 0, $e);
            }
            throw new RuntimeException($e->getMessage(), 0, $e);
        }

        if (!$message instanceof ChatMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['status'] = $message->getSubject();
        $response = null;

        try {
            if (isset($options['attach'])) {
                $options['media_ids'] = $this->uploadMedia($options['attach']);
                unset($options['attach']);
            }

            $response = $this->request('POST', '/api/v1/statuses', ['json' => $options]);
            $statusCode = $response->getStatusCode();
            $result = $response->toArray(false);
        } catch (ExceptionInterface $e) {
            if (null !== $response) {
                throw new TransportException($e->getMessage()$response, 0, $e);
            }

            
Home | Imprint | This part of the site doesn't use cookies.