<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sebbmeyer / php-microsoft-teams-connector example snippets
// create connector instance
$connector = new \Sebbmyr\Teams\TeamsConnector(<INCOMING_WEBHOOK_URL>);
// create card
$card = new \Sebbmyr\Teams\Cards\SimpleCard(['title' => 'Simple card title', 'text' => 'Simple card text']);
// send card via connector
$connector->send($card);
// create a custom card
$card = new \Sebbmyr\Teams\Cards\CustomCard('Package update', 'A custom card class was added to the package.');
// add information
$card->setColor('01BC36')
->addFactsText('Supported PHP versions',['<= 5.4.0','7.x'])
->addFactsText('Unsupported PHP versions',['Before Version 5.4'])
->addAction('Visit Github repository','https://github.com/sebbmeyer/php-microsoft-teams-connector')
->addFacts('Facts Section',['Fact Name 1' => 'Fact Value 1','Fact Name 2' => 'Fact Value 2']);
// create connector instance
$connector = new \Sebbmyr\Teams\TeamsConnector(<INCOMING_WEBHOOK_URL>);
// create data
$data = [
"body" => [
[
"type" => "TextBlock",
"text" => "Adaptive card test. For Samples and Templates, see https://adaptivecards.io/samples](https://adaptivecards.io/samples)",
],
],
];
// create card
$card = new \Sebbmyr\Teams\Cards\Adaptive\BaseAdaptiveCard($data);
// send card via connector
$connector->send($card);
// create connector instance
$connector = new \Sebbmyr\Teams\TeamsConnector(<INCOMING_WEBHOOK_URL>);
// create data
$textBlockA = new \Sebbmyr\Teams\Cards\Adaptive\Elements\TextBlock("Adaptive card");
$textBlockA->setColor( \Sebbmyr\Teams\Cards\Adaptive\Styles::COLORS_WARNING)
->setSize( \Sebbmyr\Teams\Cards\Adaptive\Styles::FONT_SIZE_LARGE)
;
$textBlockB = new \Sebbmyr\Teams\Cards\Adaptive\Elements\TextBlock("Supported by composer package sebbmeyer/php-microsoft-teams-connector");
$textBlockB->setIsSubtle(true);
$image = new \Sebbmyr\Teams\Cards\Adaptive\Elements\Image("https://adaptivecards.io/content/cats/1.png");
$image->setHorizontalAligment( \Sebbmyr\Teams\Cards\Adaptive\Styles::HORIZONTAL_ALIGNMENT_CENTER)
->setSize( \Sebbmyr\Teams\Cards\Adaptive\Styles::IMAGE_SIZE_MEDIUM)
;
$openUrl = new \Sebbmyr\Teams\Cards\Adaptive\Actions\OpenUrl
$openUrl = new \Sebbmyr\Teams\Cards\Adaptive\Actions\OpenUrl("https://github.com/sebbmeyer/php-microsoft-teams-connector");
$openUrl->setTitle("Open Github");
// create card
$card = new \Sebbmyr\Teams\Cards\Adaptive\CustomAdaptiveCard();
$card->addElement($textBlockA)
->addElement($textBlockB)
->addElement($image)
->addAction($openUrl)
;
// send card via connector
$connector->send($card);
// create connector instance
$connector = new \Sebbmyr\Teams\TeamsConnector(<INCOMING_WEBHOOK_URL>);
// create card
$card = new \Sebbmyr\Teams\Cards\HeroCard();
$card->setTitle("Hero Card")
->setSubtitle("Featuring Deadpool")
->addImage("https://miro.medium.com/max/3840/1*0ubYRV_WNR9iYrzUAVINHw.jpeg")
->setText("Deadpool is a fictional character appearing in American comic books published by Marvel Comics. Created by writer Fabian Nicieza and artist/writer Rob Liefeld, the character first appeared in The New Mutants #98 (cover-dated February 1991). Initially Deadpool was depicted as a supervillain when he made his first appearance in The New Mutants and later in issues of X-Force, but later evolved into his more recognizable antiheroic persona. Deadpool, whose real name is Wade Winston Wilson, is a disfigured mercenary with the superhuman ability of an accelerated healing factor and physical prowess. The character is known as the \"Merc with a Mouth\" because of his tendency to talk and joke constantly, including breaking the fourth wall for humorous effect and running gags.")
->addButton("openUrl", "Wikipedia page", "https://en.wikipedia.org/wiki/Deadpool")
;
// send card via connector
$connector->send($card);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.