承接 skrepr/teams-connector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

skrepr/teams-connector

最新稳定版本:0.3.2

Composer 安装命令:

composer require skrepr/teams-connector

包简介

A simple PHP package for sending messages to Microsoft Teams

README 文档

README

skrepr

Teams connector

Releases LICENSE Issues PR Commits Stars Forks

This package allows you to send notifications to Microsoft Teams.

Installation

You can install the package using the Composer package manager. You can install it by running this command in your project root:

composer require skrepr/teams-connector

Then create an incoming webhook on your Microsoft teams channel for the package to use.

Basic Usage

Create a simple card

<?php

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);

Adding a section

<?php

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);

Adding actions and inputs to the card

<?php

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);

HTTP Clients

In order to talk to Microsoft Teams API, you need an HTTP adapter. We rely on HTTPlug which defines how HTTP message should be sent and received. You can use any library to send HTTP messages that implements php-http/client-implementation.

Testing

composer test

Credits

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 8.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-07