定制 lupuscoding/webhook-teams 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

lupuscoding/webhook-teams

Composer 安装命令:

composer require lupuscoding/webhook-teams

包简介

A small library to create messages for Microsoft Teams

README 文档

README

A small library to create messages for Microsoft Teams.

Contents

Requirements #

  • PHP >= 7.4

Install #

composer require lupuscoding/webhook-teams

Usage #

Create a message card

// Insert uses
use LupusCoding\Webhooks\Teams\MessageCard;
use LupusCoding\Webhooks\Teams\ThemeColor;
// Create the card
$card = new MessageCard();
$card->setThemeColor(ThemeColor::SUCCESS)
    ->setSummary('My summary');

Create a message card section

use LupusCoding\Webhooks\Teams\MessageSection;
use LupusCoding\Webhooks\Teams\MessageCard;
// Create the section
$section = new MessageSection();
$section->setActivityTitle('My activity')
    ->setActivitySubtitle('This is a subtitle')
    ->setActivityImage('https://some/image.png')
    ->addFact('My fact', 'This is awesome')
    ->setMarkdown(false);
// Add section to card
$card = new MessageCard();
$card->addSection($section);

Create an action card

// Insert uses
use LupusCoding\Webhooks\Teams\ActionCard;
use LupusCoding\Webhooks\Teams\ThemeColor;
// Create the card
$card = new ActionCard();
$card->setName('my-action-name')
    ->setThemeColor(ThemeColor::DEBUG);

Create an action card input

use LupusCoding\Webhooks\Teams\ActionCard;
use LupusCoding\Webhooks\Teams\Input\TextInput;
// Create the input
$input = new TextInput();
$input->setId('input1')
    ->setTitle('Type something in')
    ->setMultiline(true)
    ;
// Add input to card
$card = new ActionCard();
$card->addInput($input);

Create an action card action

use LupusCoding\Webhooks\Teams\ActionCard;
use LupusCoding\Webhooks\Teams\CardAction\HttpPost;
// Create the action
$action = new HttpPost();
$action->setName('Click me')
    ->setTarget('http://lupuscoding.de');
// Add action to card
$card = new ActionCard();
$card->addAction($action);

Send a card

use LupusCoding\Webhooks\Teams\MessageCard;
$card = new MessageCard();
    
// Setup the hook url
$hookUrl = 'https://webhook.site/253013d5-4960-4857-85c4-596998c26e10';
// Init curl request
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_URL, $hookUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($card));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:application/x-www-form-urlencoded']);
// Send request
$result = curl_exec($ch);
curl_close($ch);
// Test result
if (curl_errno($ch)) {
    // Failure
} else {
    // Success
}

Development #

  • Every contribution should respect PSR-2 and PSR-12.
  • Methods must provide argument types and return types.
  • Class properties must be typed.
  • doc blocks must only contain descriptive information.
  • doc blocks may additionally contain a type declaration for arguments or return values, if the type declaration is not precise.

For example: func(): array may not be precise if the method returns an array of arrays or objects. Consider a doc block entry like @return array[] or @return MyObject[] for clarification.

Testing #

First install phpunit by executing

composer install

Then start phpunit by executing

vendor/bin/phpunit

Further Testing (optional)

Every test request is sent to Pipedream. This site processes the requests and build valid responses. Also every request is forwarded to this Request Bin, so that you can view the request data.

To inspect the requests, you can login with your GitHub account and copy my published Webhook Workflow. Please make sure to change the publicBinUrl variable inside the workflow nodejs step, to your own Request Bin.
After creating your Pipedream Webhook Workflow, just modify the WEBHOOK_URL constant inside the MessageCardTest and ActionCardTest class.*

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固