如何獲取 Teams Meeting 的上下文信息

我們上一篇文章講了如果使用 net6 和 c# 來快速開發一個最簡單的 teams meeting app。為了讓大家比較容易理解,上個sample非常簡單,簡單到沒有什么功能,那我們現在就來慢慢擴展這個app的功能:看看如何獲取 meeting 的上下文。

打開上個sample中的?MainPage.cshtml?文件,使用如下代碼:

@page "/MainPage"<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Demo</title><link rel="stylesheet" href="/static/styles.css"><script src="https://statics.teams.cdn.office.net/sdk/v1.10.0/js/MicrosoftTeams.min.js"integrity="sha384-6oUzHUqESdbT3hNPDDZUa/OunUj5SoxuMXNek1Dwe6AmChzqc6EJhjVrJ93DY/Bv"crossorigin="anonymous"></script>
</head>
<body><h1>MainPage</h1><div id="meeting-context"></h1><script>microsoftTeams.initialize();microsoftTeams.getContext(function(context) {document.getElementById('meeting-context').innerText = JSON.stringify(context);});</script>
</body>
</html>

這段代碼比較簡單,首先加入了對 teams js sdk 的引用,版本為 1.10.0,然后調用了下面這個方法:

microsoftTeams.initialize();

這個是對sdk的初始化,由于我們這個頁面是會嵌入到 teams 會議中的,所以?MainPage?頁面需要和 Teams客戶端本身建立一種聯系。這個是一個必要步驟,如果不做這個,其他大多數函數都會失敗。

然后我們就調用了?microsoftTeams.getContext(function(context) { ... });,這就是用來獲取會議上下文的 api。在sdk里,這個方法的定義如下。https://github.com/DefinitelyTyped/DefinitelyTyped/blob/8bd26b379caa1f82a24aa1bb768d92fe9f30950b/types/microsoftteams/index.d.ts

function getContext(callback: (context: Context) => void): void;interface Context {groupId?: string | undefined;teamId?: string | undefined;teamName?: string | undefined;channelId?: string | undefined;channelName?: string | undefined;channelType?: ChannelType | undefined;entityId: string;subEntityId?: string | undefined;locale: string;osLocaleInfo?: LocaleInfo | undefined;upn?: string | undefined;tid?: string | undefined;theme?: string | undefined;isFullScreen?: boolean | undefined;teamType?: TeamType | undefined;teamSiteUrl?: string | undefined;teamSiteDomain?: string | undefined;teamSitePath?: string | undefined;hostTeamTenantId?: string | undefined;hostTeamGroupId?: string | undefined;channelRelativeUrl?: string | undefined;sessionId?: string | undefined;userTeamRole?: UserTeamRole | undefined;chatId?: string | undefined;loginHint?: string | undefined;userPrincipalName?: string | undefined;userObjectId?: string | undefined;isTeamArchived?: boolean | undefined;hostClientType?: HostClientType | undefined;frameContext?: FrameContexts | undefined;sharepoint?: any;tenantSKU?: string | undefined;userLicenseType?: string | undefined;parentMessageId?: string | undefined;ringId?: string | undefined;appSessionId?: string | undefined;isCallingAllowed?: boolean | undefined;isPSTNCallingAllowed?: boolean | undefined;meetingId?: string | undefined;defaultOneNoteSectionId?: string | undefined;isMultiWindow?: boolean | undefined;appIconPosition?: number | undefined;sourceOrigin?: string | undefined;userClickTime?: number | undefined;teamTemplateId?: string | undefined;userFileOpenPreference?: FileOpenPreference | undefined;
}

可以看到 Context 是一個有非常多屬性的結構,我們不展開,我們先來看一下安裝后我們得到的 context是什么,在我們上面的代碼里,我們把拿到的 context 序列化成 json,然后打印在頁面上。

我們安裝 app 到一個會議中,然后就可以看到頁面上顯示了 context 的json數據。

get-context

我們來看一下這個json里含了什么有用的信息:

{"locale": "en-us","theme": "default","entityId": null,"subEntityId": "","isFullScreen": false,"sessionId": "91291367-f8f0-9a5e-d420-490d4eb8bc8d","chatId": "19:meeting_ODA1MjIzYzAtODNhYy00MjE0LWFmZmQtN2MxMTQ0ODdlMWQ2@thread.v2","meetingId": "MCMxOTptZWV0aW5nX09EQTFNakl6WXpBdE9ETmhZeTAwTWpFMExXRm1abVF0TjJNeE1UUTBPRGRsTVdRMkB0aHJlYWQudjIjMA==","parentMessageId": "","hostClientType": "desktop","tenantSKU": "enterprise","jsonTabUrl": "microsoft-teams-json-tab.azurewebsites.net","userLicenseType": "Unknown","appSessionId": "1be21c3a-e846-4bf8-90e3-dc3b01938d39","appLaunchId": "d30e788c-d424-40f5-9373-236345d64249","isMultiWindow": false,"appIconPosition": 23,"userClickTime": 1640572621827,"sourceOrigin": null,"userFileOpenPreference": "inline","osLocaleInfo": {"platform": "windows","regionalFormat": "en-us","longDate": "dddd, MMMM d, yyyy","shortDate": "M/d/yyyy","longTime": "h:mm:ss tt","shortTime": "h:mm tt"},"frameContext": "content","teamSiteDomain": "aabbcc365.sharepoint.com","teamSitePath": "","teamSiteUrl": "","ringId": "general","tid": "53213f63-c1e6-4416-bdab-da54fcb7b4b7","loginHint": "admin@aabbcc365.onmicrosoft.com","upn": "admin@aabbcc365.onmicrosoft.com","userPrincipalName": "admin@aabbcc365.onmicrosoft.com","userObjectId": "488e5982-c57c-4373-a4dd-67eab506d98d"
}

有這么一些信息我覺得比較有用:

  • locale 當前 Teams 客戶端的語言
  • theme 當前 Teams 客戶端的主題,比如是不是暗色主題,或者是高對比度主題
  • meetingId 當前會議的唯一id
  • hostClientType 當前 Teams 客戶端的類型
    enum HostClientType {desktop = "desktop",web = "web",android = "android",ios = "ios",rigel = "rigel",surfaceHub = "surfaceHub"
    }
    
  • osLocaleInfo 當前 Teams 客戶端的文化信息,比如日期格式之類的
  • tid 當前租戶的id
  • userPrincipalName 用戶名
  • userObjectId 當前用戶的 Azure AD里的Object ID

我們有了這些信息后(特別是meeting id),后面很多 api 就比較容易調用了,我們將在后面的文章里再具體展開。

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/277847.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/277847.shtml
英文地址,請注明出處:http://en.pswp.cn/news/277847.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

php的運行流程

1、Zend引擎&#xff1a;Zend整體用純C實現&#xff0c;是PHP的內核部分&#xff0c;他將PHP代碼翻譯&#xff08;詞法、語法解析等一系列編譯過程&#xff09;為可執行opcode的處理并實現相應的處理方法、實現了基本的數據結構&#xff08;如&#xff1a;hashtable、OO&#x…

內置方法

isinstance(obj,cls)和issubclass(sub,super) isinstance(obj,cls)檢查是否obj是否是類 cls 的對象 class Foo(object):pass obj Foo() isinstance(obj, Foo) issubclass(sub, super)檢查sub類是否是 super 類的派生類 class Foo(object):pass class Bar(Foo):pass issubclass…

會議中的Meeting App

接著我們上兩篇博客文章&#xff0c;我們說了如何開發會議前和會議后的 meeting app&#xff0c;那如何開發一個會議中的 app 呢&#xff0c;實際上比較簡單&#xff0c;我們只需要在 tab 的配置項中勾選下面這兩個選項即可。 勾選后&#xff0c;我們安裝app到我們的一個會議中…

0-2歲的app開發人員必讀,Android開發APP前的準備事項

2019獨角獸企業重金招聘Python工程師標準>>> 隨著移動互聯網的興起&#xff0c;各行各業對移動應用的需求越來越大&#xff0c;從事APP開發的人也越來越多&#xff0c;APP開發行業可以說是方興未艾。APP開發是比較復雜的事情&#xff0c;涉及產品、美工設計、服務器…

FixedThreadPool吞掉了異常

為了方便遍描述問題&#xff0c;如下是簡化后的 public class RunException {public static void main(String[] args) { ExecutorService readerPool Executors.newFixedThreadPool(3); readerPool.submit(new Runnable() { public void run() { throw new RuntimeException(…

Teams Meeting App的 task 彈出框

前幾篇文章我們介紹了 Teams Meeting App 的各種類型和如何從無到有的使用 net6 和 c# 來開發一個 Teams Meeting app&#xff0c;那今天我們開始討論一些 meeting app 的高級互動&#xff1a; task 彈出框。我們先來快速修改一下之前的代碼&#xff0c;看看什么是 task 彈出框…

react 學習

react官網地址&#xff1a;http://facebook.github.io/react/ webpack官網地址&#xff1a;http://webpack.js.org/ 英文 https://www.webpackjs.com/ 中文 參考資料&#xff1a; React 入門實例教程-阮一峰 webpack的學習 學習列表&#xff1a; 了解react的語法&#x…

如何獲取Teams Meeting 詳情

最近有一些朋友問我&#xff0c;有沒有可能獲取到會議的詳情&#xff0c;我搜索了目前所有的 teams 文檔&#xff0c;發現有一個api可以獲取&#xff0c;不過在我寫這篇文章的時候&#xff0c;這個 api 還在 preview 階段&#xff0c;可能在正式發布前&#xff0c;還會有一些變…

C++ : 內聯函數和引用變量

一.內聯函數 內聯函數和普通函數的使用方法沒有本質區別&#xff0c;我們來看一個例子&#xff0c;下面展示了內聯函數的使用方法&#xff1a; #include <iostream> using namespace std; //下面展示內聯函數的使用 inline double square(double x) {return (x*x);} int…

Teams Meeting 實時事件通知

Microsoft Teams最近推出了很多新的功能和api&#xff0c;我們今天就來一起看一下 teams 會議的實時事件通知&#xff0c;我覺得有了這個功能&#xff0c;我們的app&#xff0c;我們的bot又可以有很多可以實現的場景了。 我們來看看如何在 c# 里處理會議開始和結束這兩個事件。…

error記錄 | 不能將參數 1 從“const char [5]”轉換為“LPCTSTR

Windows使用兩種字符集ANSI和UNICODE&#xff0c;前者就是通常使用的單字節方式&#xff0c;但這種方式處理象中文這樣的雙字節字符不方便&#xff0c;容易出現半個漢字的情況。而后者是雙字節方式&#xff0c;方便處理雙字節字符。Windows NT的所有與字符有關的函數都提供兩…

JMM 學習筆記

并發編程的模型 并發編程需要解決的兩個問題&#xff1a;線程之間如何同步&#xff0c;線程之間如何通信。 線程之間通信&#xff1a;共享內存&#xff0c;消息傳遞。 共享內存通過線程之間讀-寫程序的公共狀態進行通信。消息傳遞要通過線程之間主動傳遞消息進行通信。 線程之間…

嵌套函數,匿名函數,高階函數

目錄 嵌套函數匿名函數高階函數嵌套函數 就是在函數里再定義一個函數 # 1,函數內部可以在定義函數 # 2,函數要想執行&#xff0c;必須要先被調用 def name1():print(kk)def name2():print(vfx)name2() name1() 輸出&#xff1a; kk vfx name2 現在他內部代碼找輸出&#xff0c;…

Teams Developer Portal介紹

在去年的 Build2021 大會上講到的 Teams Developer Portal 已經上線一段時間了&#xff0c;我這幾天玩了一下&#xff0c;發現比之前的 app studio 強大了很多&#xff0c;所以趕快寫篇文章和大家分享。 Developer Portal 有兩種訪問的方式&#xff0c;一個是網頁版&#xff0…

使用環境變量來配置 Teams App 的 manifest

上篇文章我們介紹了 Teams 的 Developer Portal&#xff0c;今天我想分享一個dev portal里一個比較實用的功能。這個功能在之前的 App Studio 里沒有。這個功能叫 Environment variables。 當我們真實開發一個 teams app的時候&#xff0c;肯定有自己的開發環境&#xff0c;測…

[Unity優化]批處理03:靜態批處理

[Unity優化]批處理03&#xff1a;靜態批處理 原理&#xff1a; 運行時&#xff0c;把需要進行靜態批處理的網格合并到一個新的網格中。雖然只進行一次合并操作&#xff0c;但是會占用更多的內存來存儲合并后的網格&#xff0c;并且被靜態批處理的物體無法移動旋轉縮放 要使用靜…

制造領域的人工智能技術

“AI將執行制造、質量控制、縮短設計時間、減少材料浪費、提高生產再利用率&#xff0c;執行預測性維護等等&#xff0c;盡管人工智能有望從根本上改變很多行業&#xff0c;但該技術非常適合制造業”Ng說。Andrew Ng是深度學習Google Brain項目的創始人兼斯坦福大學計算機科學兼…

如何獲取一個會議的 transcripts

Teams 開發團隊在過去半年里提供了很多的關于會議的 api&#xff0c;這讓我們又有了很多的可以實現的功能和場景。今天我要介紹的是如何獲取會議的 transcripts。 首先我們要知道的一個概念是&#xff1a;一個會議 meeting 可能有很多的 transcript&#xff0c;是一對多的關系…

JS獲取IP地址

HTML代碼&#xff1a; <!DOCTYPE html> <html><head><meta charset"UTF-8"><title></title><script src"https://unpkg.com/vue/dist/vue.js"></script></head><body><div id"vm&quo…

1小時玩爆趣頭條自媒體平臺,增粉實戰操作分享

做自媒體的人最關注的就是每天自己賬號的后臺數據&#xff0c;因為數據決定當天的收益。因此只要每天能達到幾十萬的數據&#xff0c;相信對于做自媒體的朋友來說&#xff0c;一個月下來&#xff0c;最少也有1萬以上的收入。目前&#xff0c;自媒體平臺能賺錢的平臺有很多&…