Download the PHP package rocketfellows/ms-teams-webhook-message-sender without Composer
On this page you can find all versions of the php package rocketfellows/ms-teams-webhook-message-sender. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ms-teams-webhook-message-sender
Microsoft Teams webhook message sender.
This package is designed for sending messages to Microsoft Teams (MS Teams) channels using webhooks (incoming webhook or connector). For more information about sending messages to MS Teams channels using web hooks see https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL.
Installation.
Dependencies.
Current implementation dependencies:
- guzzle client - https://github.com/guzzle/guzzle - using for http request to webhook.
MS Teams webhook message sender description.
Basic package types.
Connector.
rocketfellows\MSTeamsWebhookMessageSender\configs\Connector
- a class that encapsulates the connection configuration for sending a message.
Class description:
incomingWebhookUrl
- string - link to a webhook (connector) for sending a message;create
- static function - static factory function that returns a value of typeConnector
;getIncomingWebhookUrl
- function - getter that returns the value of theincomingWebhookUrl
attribute.
Message.
rocketfellows\MSTeamsWebhookMessageSender\models\Message
- a class that encapsulates message data to be sent via a webhook and implements the JsonSerializable
interface.
Class description:
text
- string - message text to send;title
- string | null - message title to send;create
- static function - static factory function returning a value of typeMessage
;convertToJson
- function - function, returns a representation of aMessage
type value as a json string;jsonSerialize
- function - implementation of theJsonSerializable
interface;getText
- function - getter returningtext
attribute value;getTitle
- function - getter returningtitle
attribute value.
Interfaces.
MSTeamsWebhookMessageSenderInterface.
rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookMessageSenderInterface
- interface for sending a message via a webhook uses a Connector
type value as a connection, and a Message
type value as a message.
Interface exceptions:
EmptyIncomingWebhookUrlException
- thrown if the link to the webhook is an empty string.InvalidIncomingWebhookUrlException
- thrown if the link to the webhook is not valid (for example, the link is not an url).EmptyMessageException
- thrown if the message text is an empty string.ConnectorException
- thrown if an error occurred when sending a message (for example, if the HTTP response code is not 200).
Usage examples.
Send message with title:
Result:
Send message without title:
Result:
MSTeamsWebhookTextSenderInterface.
rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookTextSenderInterface
- interface for sending a message via a webhook uses a value of type Connector
as a connection, and a value of type string (message text) as a message.
Interface exceptions:
EmptyIncomingWebhookUrlException
- thrown if the link to the webhook is an empty string.InvalidIncomingWebhookUrlException
- thrown if the link to the webhook is not valid (for example, the link is not an url).EmptyMessageException
- thrown if the message text is an empty string.ConnectorException
- thrown if an error occurred when sending a message (for example, if the HTTP response code is not 200).
Usage examples.
Send text:
Result:
MSTeamsWebhookArrayMessageSenderInterface.
rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookArrayMessageSenderInterface
- interface for sending a message via a webhook uses a Connector
type value as a connection, and an array type value as a message.
Interface exceptions:
EmptyIncomingWebhookUrlException
- thrown if the link to the webhook is an empty string.InvalidIncomingWebhookUrlException
- thrown if the link to the webhook is not valid (for example, the link is not an url).EmptyMessageDataException
- thrown if the array with message data is empty.ConnectorException
- thrown if an error occurred when sending a message (for example, if the HTTP response code is not 200).
Usage examples.
Send message with title:
Result:
Send message without title:
Result:
Send message with section:
Result:
MSTeamsWebhookJsonMessageSenderInterface.
rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookJsonMessageSenderInterface
- interface for sending a message via a webhook uses a value of type Connector
as a connection, and a value of type string (a json string with message data) as a message.
Interface exceptions:
EmptyIncomingWebhookUrlException
- thrown if the link to the webhook is an empty string.InvalidIncomingWebhookUrlException
- thrown if the link to the webhook is not valid (for example, the link is not an url).EmptyMessageDataException
- thrown if the array with message data is empty.InvalidJsonMessageException
- thrown if the json string with the message data is not valid (not valid from the point of view of the json format).ConnectorException
- thrown if an error occurred when sending a message (for example, if the HTTP response code is not 200).
Usage examples.
Send message with title:
Result:
Send message without title:
Result:
Send message with sections:
Result:
Interfaces implementation.
MSTeamsWebhookMessageSender.
rocketfellows\MSTeamsWebhookMessageSender\senders\MSTeamsWebhookMessageSender
- service for sending messages via a webhook.
Sender implements the following interfaces:
rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookMessageSenderInterface
;rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookTextSenderInterface
;rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookArrayMessageSenderInterface
;rocketfellows\MSTeamsWebhookMessageSender\MSTeamsWebhookJsonMessageSenderInterface
.
GuzzleHttp Client
is used to send a request with a message.
Usage examples.
Sending a Message
without a title:
Result:
Sending a Message
with a title:
Result:
Sending a message as a string:
Result:
Sending a message as an array:
Result:
Sending a message as a json string:
Result:
Contributing.
Welcome to pull requests. If there is a major changes, first please open an issue for discussion.
Please make sure to update tests as appropriate.