ejtj3/teams

此包已被放弃,不再维护。未建议替代包。

一个简单的PHP包,用于向MS teams发送消息

0.1.3 2021-07-23 12:15 UTC

This package is auto-updated.

Last update: 2021-12-04 11:01:24 UTC


README

警告:此包已移动到其他存储库:https://github.com/skrepr/teams-connector

一个用于向Microsoft Teams发送消息的非常简单的PHP包,使用入站webhook,注重易用性和优雅的语法。

要求

  • PHP 7.2+

安装

您可以使用Composer包管理器安装此包。您可以在项目根目录中运行以下命令进行安装:

composer require ejtj3/teams

然后为该包在Microsoft teams通道上[创建一个入站webhook],以便包可以使用。

基本用法

创建一个简单的卡片

<?php

declare(strict_types=1);

use EJTJ3\Teams\Card;
use EJTJ3\Teams\Client;

$client = new Client('https://...');

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

$client->send($card);

添加一个部分

<?php

declare(strict_types=1);

use EJTJ3\Teams\Card;
use EJTJ3\Teams\Section;

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

向卡片添加操作 & 输入

<?php

declare(strict_types=1);

use EJTJ3\Teams\Card;
use EJTJ3\Teams\Actions\ActionCard;
use EJTJ3\Teams\Actions\HttpPostAction;
use EJTJ3\Teams\Inputs\TextInput;

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

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