首页 > 解决方案 > 如何格式化 JSON 数据以使用 POSTMAN 或 PHP cURL 以表格格式向 Microsoft Teams 发送消息

问题描述

我有一个特定频道的 MS Teams 的 webhook。我必须以表格格式向该频道发送消息。该表将有一个标题和正文。我可以使用 POSTMAN 和 PHP cURL 向 MS Teams 频道发送简单的短信。

JSON 格式应在此处有效:https ://messagecardplayground.azurewebsites.net

标签: phpcurlmicrosoft-teams

解决方案


您可以使用自适应卡片中的列集来呈现类似卡片的表格

示例:卡片 Json -

 {
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "body": [
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "TItle1",
                            "separator": true
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body1"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body4"
                        }
                    ],
                    "width": "stretch",
                    "style": "accent"
                },
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "title2"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body2"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body5"
                        }
                    ],
                    "width": "stretch",
                    "style": "good"
                },
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "title3"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body3"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body6"
                        }
                    ],
                    "width": "stretch",
                    "style": "warning"
                }
            ]
        }
    ]
}

卡片呈现如下:

在此处输入图像描述


推荐阅读