PHP code example of skrepr / teams-connector

1. Go to this page and download the library: Download skrepr/teams-connector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

skrepr / teams-connector example snippets




declare(strict_types=1);

use Skrepr\TeamsConnector\Card;
use Skrepr\TeamsConnector\CardInterface;
use Skrepr\TeamsConnector\Client;

$endPoint = 'https://...';
$httpClient = new \GuzzleHttp\Client();
$teamsClient = new Client($endPoint, $httpClient);

$card = (new Card('Larry Bryant created a new task'))
    ->setText('Yes, he did')
    ->setThemeColor(CardInterface::STATUS_DEFAULT)
    ->setTitle('Adding Title to the card');

$teamsClient->send($card);



declare(strict_types=1);

use Skrepr\TeamsConnector\Card;
use Skrepr\TeamsConnector\Client;
use Skrepr\TeamsConnector\Section\Section;

$endPoint = 'https://...';
$httpClient = new \GuzzleHttp\Client();
$teamsClient = new Client($endPoint, $httpClient);

$card = new Card('Larry Bryant created a new task');

$section = (new Section('![TestImage](https://47a92947.ngrok.io/Content/Images/default.png)Larry Bryant created a new task'))
    ->setActivitySubtitle('On Project Tango')
    ->setActivityImage('https://teamsnodesample.azurewebsites.net/static/img/image5.png')
    ->addFact('Assigned to', 'Unassigned')
    ->addFact('Due date', 'Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)');

$card->addSection($section);

$teamsClient->send($card);



declare(strict_types=1);

use Skrepr\TeamsConnector\Actions\ActionCard;
use Skrepr\TeamsConnector\Actions\HttpPostAction;
use Skrepr\TeamsConnector\Card;
use Skrepr\TeamsConnector\Client;
use Skrepr\TeamsConnector\Inputs\TextInput;

$endPoint = 'https://...';
$httpClient = new \GuzzleHttp\Client();
$teamsClient = new Client($endPoint, $httpClient);

$card = new Card('Larry Bryant created a new task');
$card->setText('Yes, he did');

$actionCard = (new ActionCard('Add a comment'))
    ->addInput(new TextInput('comment', 'Add a comment here for this task'))
    ->addAction(new HttpPostAction('Add comment', 'http://...'));

$card->addPotentialAction($actionCard);

$teamsClient->send($card);