largeQ
我们在图形 API 的帮助下实现了同样的目标注意:向通道发送消息目前处于测试阶段,但很快就会转移到图 V1 端点。使用 HTTP:POST https://graph.microsoft.com/beta/teams/{id}/channels/{id}/messagesContent-type: application/json{ "body": { "content": "Hello World" }}使用 C#:GraphServiceClient graphClient = new GraphServiceClient( authProvider );var chatMessage = new ChatMessage{ Subject = null, Body = new ItemBody { ContentType = BodyType.Html, Content = "<attachment id=\"74d20c7f34aa4a7fb74e2b30004247c5\"></attachment>" }, Attachments = new List<ChatMessageAttachment>() { new ChatMessageAttachment { Id = "74d20c7f34aa4a7fb74e2b30004247c5", ContentType = "application/vnd.microsoft.card.thumbnail", ContentUrl = null, Content = "{\r\n \"title\": \"This is an example of posting a card\",\r\n \"subtitle\": \"<h3>This is the subtitle</h3>\",\r\n \"text\": \"Here is some body text. <br>\\r\\nAnd a <a href=\\\"http://microsoft.com/\\\">hyperlink</a>. <br>\\r\\nAnd below that is some buttons:\",\r\n \"buttons\": [\r\n {\r\n \"type\": \"messageBack\",\r\n \"title\": \"Login to FakeBot\",\r\n \"text\": \"login\",\r\n \"displayText\": \"login\",\r\n \"value\": \"login\"\r\n }\r\n ]\r\n}", Name = null, ThumbnailUrl = null } }};await graphClient.Teams["{id}"].Channels["{id}"].Messages .Request() .AddAsync(chatMessage);您可能需要查看官方文档以获得更清晰的信息。这是下面的链接https://learn.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-beta&tabs=csharp就我而言,我使用 Angular 并调用端点。希望它能提供一些想法。