发送不同类型的ActivityFeed
上一篇文章講到了如何使用最新的Graph API來給一個用戶發送一個簡單的 Activity Feed。我們這篇文章來詳細講一下發送三種不同類型的消息。
發送 Chat 相關的 Activity Notification
API 為?POST https://graph.microsoft.com/beta/chats/{chat-id}/sendActivityNotification
http請求的內容為:
{"topic": {"source": "entityUrl","value": "https://graph.microsoft.com/beta/chats/{chat-id}"},"activityType": "taskCreated","previewText": {"content": "New Task Created"},"recipient": {"@odata.type": "microsoft.graph.aadUserNotificationRecipient","userId": "569363e2-1111-2222-3333-16f245c5d66a"},"templateParameters": [{"name": "taskId","value": "Task 12322"}] }其中?activityType?和?templateParameters?我已經在前面一篇文章中介紹過,previewText?從名字上也很容易理解,是推送的消息的文本內容,recipient?是接受推送消息的用戶的 id 信息。
這里比較關鍵的是?topic,這個指明了這個推送的消息是針對哪個聊天 (chat) 或者哪個 聊天消息 (chatMessage) 的,如果是針對 chat 的,那么?topic?里的?value?就是?https://graph.microsoft.com/beta/chats/{chat-id}?這種格式,如果是 chatMessage,格式就是?https://graph.microsoft.com/beta/chats/{chat-id}/messages/{message-id}
大家可能會問,如何獲得這個 chat id 和 message id 呢,這兩個可以在發送 message 是返回,或者也可以通過調用 graph api 來獲取。
發送 Team 相關的 Activity Notification
API 為?POST https://graph.microsoft.com/beta/teams/{teamId}/sendActivityNotification
http請求的內容和之前的很像:
{"topic": {"source": "entityUrl","value": "https://graph.microsoft.com/beta/teams/{team-id}"},"activityType": "pendingFinanceApprovalRequests","previewText": {"content": "Internal spending team has a pending finance approval requests"},"recipient": {"@odata.type": "microsoft.graph.aadUserNotificationRecipient","userId": "569363e2-1111-2222-3333-16f245c5d66a"},"templateParameters": [{"name": "pendingRequestCount","value": "5"}] }它支持的 entity url 有好幾種:
- team,格式為?https://graph.microsoft.com/beta/teams/{team-id}
- channel,格式為?https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}
- chatMesage,格式為?https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/messages/{message-id}
- teamsTab,格式為?https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/tabs/{tab-id}
發送 User 相關的 Activity Notification
API 為?POST https://graph.microsoft.com/beta/users/{userId}/teamwork/sendActivityNotification
http請求的內容和之前的很像:
{"topic": {"source": "entityUrl","value": "https://graph.microsoft.com/beta/users/{user-id}/teamwork/installedApps/{installation-id}"},"activityType": "taskCreated","previewText": {"content": "New Task Created"},"templateParameters": [{"name": "taskId","value": "Task 342342"}] }它支持的 entity url 有兩種:
- teamsAppInstallation,格式為?https://graph.microsoft.com/beta/users/{user-id}/teamwork/installedApps/{installation-id}
- teamsCatalogApp,格式為?https://graph.microsoft.com/beta/appCatalogs/teamsApps/{app-id}
總結
以上是生活随笔為你收集整理的发送不同类型的ActivityFeed的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信微信人工客服电话/微信客服怎么正确拨
- 下一篇: c++万能头文件包含的头文件