UnsupportedMessageTypeException example

return sprintf('infobip://%s?from=%s', $this->getEndpoint()$this->from);
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage;
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $endpoint = sprintf('https://%s/sms/2/text/advanced', $this->getEndpoint());

        $response = $this->client->request('POST', $endpoint[
            'headers' => [
                'Authorization' => 'App '.$this->authToken,
            ],
            'json' => [
                'messages' => [
                    [
                        
return sprintf('sendberry://%s?from=%s', $this->getEndpoint()$this->from);
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage;
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $from = $message->getFrom() ?: $this->from;

        if (!preg_match('/^[+]+[1-9][0-9]{9,14}$/', $from)) {
            if ('' === $from) {
                throw new IncompleteDsnException('This phone number is invalid.');
            }

            if (!preg_match('/^[a-zA-Z0-9 ]+$/', $from)) {
                throw new IncompleteDsnException('The Sender ID is invalid.');
            }
return sprintf('gatewayapi://%s?from=%s', $this->getEndpoint()$this->from);
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage && (null === $message->getOptions() || $message->getOptions() instanceof GatewayApiOptions);
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['sender'] = $message->getFrom() ?: $this->from;
        $options['recipients'] = [['msisdn' => $message->getPhone()]];
        $options['message'] = $message->getSubject();

        $endpoint = sprintf('https://%s/rest/mtsms', $this->getEndpoint());

        $response = $this->client->request('POST', $endpoint[
            'auth_basic' => [$this->authToken, ''],
            
return sprintf('sinch://%s?from=%s', $this->getEndpoint()$this->from);
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage;
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $endpoint = sprintf('https://%s/xms/v1/%s/batches', $this->getEndpoint()$this->accountSid);
        $response = $this->client->request('POST', $endpoint[
            'auth_bearer' => $this->authToken,
            'json' => [
                'from' => $message->getFrom() ?: $this->from,
                'to' => [$message->getPhone()],
                'body' => $message->getSubject(),
            ],
        ]);

        
return sprintf('novu://%s', $this->getEndpoint());
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof PushMessage && (null === $message->getOptions() || $message->getOptions() instanceof NovuOptions);
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof PushMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, PushMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];

        $body = [
            'name' => $message->getSubject(),
            'to' => [
                'subscriberId' => $message->getRecipientId(),
                'firstName' => $options['firstName'],
                'lastName' => $options['lastName'],
                'email' => $options['email'],
                
return $message instanceof PushMessage && (null === $message->getOptions() || $message->getOptions() instanceof PushoverOptions);
    }

    public function __toString(): string
    {
        return sprintf('pushover://%s', $this->getEndpoint());
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof PushMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, PushMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['message'] = $message->getContent();
        $options['title'] = $message->getSubject();
        $options['token'] = $this->appToken;
        $options['user'] = $this->userKey;

        $endpoint = sprintf('https://%s/1/messages.json', $this->getEndpoint());
        $response = $this->client->request('POST', $endpoint[
            'body' => $options,
        ]);
public function supports(MessageInterface $message): bool
    {
        return $message instanceof ChatMessage && (null === $message->getOptions() || $message->getOptions() instanceof TelegramOptions);
    }

    /** * @see https://core.telegram.org/bots/api */
    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof ChatMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['chat_id'] ??= $message->getRecipientId() ?: $this->chatChannel;
        $options['text'] = $message->getSubject();

        if (!isset($options['parse_mode']) || TelegramOptions::PARSE_MODE_MARKDOWN_V2 === $options['parse_mode']) {
            $options['parse_mode'] = TelegramOptions::PARSE_MODE_MARKDOWN_V2;
            $options['text'] = preg_replace('/([_*\[\]()~`>#+\-=|{}.!\\\\])/', '\\\\$1', $message->getSubject());
        }

        
public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage;
    }

    /** * https://simpletexting.com/api/docs/v2/. */
    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }
        $endpoint = sprintf('https://%s/v2/api/messages', $this->getEndpoint());

        $options = [];
        $options['text'] = $message->getSubject();
        $options['contactPhone'] = $message->getPhone();
        $options['mode'] = 'AUTO';
        $options['accountPhone'] = $message->getFrom() ?: $this->from;

        if (null !== $options['accountPhone'] && !preg_match('/^\+?[1-9]\d{1,14}$/', $options['accountPhone'])) {
            throw new InvalidArgumentException(sprintf('The "From" number "%s" is not a valid phone number.', $options['accountPhone']));
        }
return $message instanceof SmsMessage;
    }

    /** * @param MessageInterface|SmsMessage $message * * @throws TransportExceptionInterface */
    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$this->supports($message)) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $email = (new Email())
            ->from($message->getFrom() ?: $this->from)
            ->to($this->to)
            ->subject(sprintf('New SMS on phone number: %s', $message->getPhone()))
            ->html($message->getSubject())
            ->text($message->getSubject());

        if ('default' !== $transportName = $this->getEndpoint()) {
            $email->getHeaders()->addTextHeader('X-Transport', $transportName);
        }
true
        ));

        $options['headers'][] = 'Authorization: OAuth '.implode(', ', array_map(fn ($k) => $k.'="'.rawurlencode($oauth[$k]).'"', array_keys($oauth)));

        return $this->client->request($method$url$options);
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        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']);
            }

            
return sprintf('smsc://%s?from=%s', $this->getEndpoint()$this->from);
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage;
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $body = [
            'login' => $this->login,
            'psw' => $this->password,
            'sender' => $message->getFrom() ?: $this->from,
            'phones' => $message->getPhone(),
            'mes' => $message->getSubject(),
            'fmt' => 3, // response as JSON             'charset' => 'utf-8',
            'time' => '0-24',
        ];
return sprintf('turbosms://%s?from=%s', $this->getEndpoint()urlencode($this->from));
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage;
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $this->assertValidSubject($message->getSubject());

        $fromMessage = $message->getFrom();

        if ($fromMessage) {
            $this->assertValidFrom($fromMessage);
            $from = $fromMessage;
        } else {
            $from = $this->from;
        }
return sprintf('vonage://%s?from=%s', $this->getEndpoint()$this->from);
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage;
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/sms/json', [
            'body' => [
                'from' => $message->getFrom() ?: $this->from,
                'to' => $message->getPhone(),
                'text' => $message->getSubject(),
                'api_key' => $this->apiKey,
                'api_secret' => $this->apiSecret,
            ],
        ]);

        
return sprintf('messagebird://%s?from=%s', $this->getEndpoint()$this->from);
    }

    public function supports(MessageInterface $message): bool
    {
        return $message instanceof SmsMessage && (null === $message->getOptions() || $message->getOptions() instanceof MessageBirdOptions);
    }

    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof SmsMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class$message);
        }

        $options = $message->getOptions()?->toArray() ?? [];
        $options['originator'] = $message->getFrom() ?: $this->from;
        $options['recipients'] = [$message->getPhone()];
        $options['body'] = $message->getSubject();

        $endpoint = sprintf('https://%s/messages', $this->getEndpoint());
        $response = $this->client->request('POST', $endpoint[
            'auth_basic' => ['AccessKey', $this->token],
            'body' => array_filter($options),
        ]);
public function supports(MessageInterface $message): bool
    {
        return $message instanceof ChatMessage && (null === $message->getOptions() || $message->getOptions() instanceof MercureOptions);
    }

    /** * @see https://symfony.com/doc/current/mercure.html#publishing */
    protected function doSend(MessageInterface $message): SentMessage
    {
        if (!$message instanceof ChatMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class$message);
        }

        if (($options = $message->getOptions()) && !$options instanceof MercureOptions) {
            throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, MercureOptions::class));
        }

        $options ??= new MercureOptions($this->topics);

        // @see https://www.w3.org/TR/activitystreams-core/#jsonld         $update = new Update($options->getTopics() ?? $this->topics, json_encode([
            '@context' => 'https://www.w3.org/ns/activitystreams',
            
Home | Imprint | This part of the site doesn't use cookies.