[英]How can I retrieve a RingCentral call recording from a monitored incoming call?
我正在通過偵聽呼叫會話通知 (CSN) telephony/sessions
事件過濾器來監視 RingCentral 上的來電:
/restapi/v1.0/account/~/extension/~/telephony/sessions
由此,我將收到如下事件。 recordings
屬性將出現以指示錄音可用。 我怎樣才能找回這個錄音?
{
"uuid":"12345678901234567890",
"event":"/restapi/v1.0/account/11111111/extension/22222222/telephony/sessions",
"timestamp":"2019-03-08T22:30:40.059Z",
"subscriptionId":"11112222-3333-4444-5555-666677778888",
"ownerId":"33333333",
"body":{
"sequence":7,
"sessionId":"1234567890",
"telephonySessionId":"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
"serverId":"10.11.12.13.TAM",
"eventTime":"2019-03-08T22:30:39.938Z",
"parties":[
{
"accountId":"11111111",
"extensionId":"22222222",
"id":"cs12345678901234567890-2",
"direction":"Inbound",
"to":{
"phoneNumber":"+16505550100",
"name":"Jane Doe",
"extensionId":"22222222"
},
"from":{
"phoneNumber":"+14155550100",
"name":"John Smith"
},
"recordings":[
{
"id":"44444444",
"active":false
}
],
"status":{
"code":"Answered",
"rcc":false
},
"missedCall":false,
"standAlone":false,
"muted":false
}
],
"origin":{
"type":"Call"
}
}
}
有兩種使用呼叫會話通知 (CSN) 事件中的信息檢索錄音的方法,特別是recordings[0].id
屬性和sessionID
屬性。
sessionId
屬性調用call-log
端點來檢索完整的媒體 URLrecordings[0].id
屬性手動創建錄制媒體 URL。注意 1:當通話正在進行時,錄音將不可檢索,即使錄音 ID 存在於呼叫會話通知事件中。 通話結束后不久即可檢索錄音。
注2:通話錄音可以是公司確定的MP3或WAV格式。 為了在檢索錄制媒體文件時區分檢查 MIME 類型的響應
Content-Type
標頭。
對call-log
API 進行中間 API 調用具有雙重好處,即作為接收媒體 URL 的官方方法和為調用提供更多元數據。 在這種方法中, recording.id
在call-log
記錄將匹配recordings[0].id
在呼叫會話通知事件屬性。
可以使用事件中的sessionId
參數call-log
公司帳戶和用戶擴展call-log
API,如下所示:
GET /restapi/v1.0/account/~/call-log?sessionId={sessionId}
GET /restapi/v1.0/account/~/extension/~/call-log?sessionId={sessionId}
在此示例中, sessionId
為1234567890
因此您將擁有如下的 Company Call Log API URL
GET /restapi/v1.0/account/~/call-log?sessionId=1234567890
響應對象將有一個recording
屬性,提供超媒體鏈接以獲取媒體文件。 該文件可以是 WAV 或 MP3 格式,在響應Content-Type
標頭中進行通信。
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log/1234567890ABCDEFGabcdefgh?view=Simple",
"id": "1234567890ABCDEFGabcdefgh",
"sessionId": "1234567890",
"startTime": "2019-03-08T22:30:29.505Z",
"duration": 35,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Accepted",
"to": {
"phoneNumber": "+16505550100",
"name": "Jane Doe"
},
"from": {
"phoneNumber": "+14155550100",
"name": "John Smith",
"location": "San Francisco, CA"
},
"recording": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444",
"id": "44444444",
"type": "OnDemand",
"contentUri": "https://media.ringcentral.com/restapi/v1.0/account/111111111/recording/44444444/content"
},
"extension": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/111111111/extension/22222222",
"id": 22222222
},
"reason": "Accepted",
"reasonDescription": "The call connected to and was accepted by this number."
}
],
"paging": {
"page": 1,
"perPage": 100,
"pageStart": 0,
"pageEnd": 0
},
"navigation": {
"firstPage": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100"
},
"lastPage": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100"
}
}
}
您可以通過手動構建錄制 URL 來調用錄制 API 端點並直接檢索媒體,如下所示:
https://media.ringcentral.com/restapi/v1.0/account/{accountId}/recording/{recordingId}/content
在此示例中, accountId
為11111111
, recordingId
為44444444
,如下所示:
https://media.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444/content
可以使用~
將 URL 路徑中的accountId
設置為當前授權用戶的帳戶。 或者,可以通過從event
屬性中提取accountId
或使用相關party
對象中的accountId
屬性來顯式設置它。 使用~
是設置accountId
的推薦方法。
注意:這種方法可能很快,但可能容易出錯,因為 RingCentral 過去曾更改過一次媒體主機名。 雖然沒有預期的未來變化,但調用
call-log
API 並從響應中檢索完整的媒體 URL 是更安全和推薦的方法。 有關此方法,請參見下文。 這僅包括在內,因為有些人會嘗試此操作並可能在以后遇到問題。
調用call-log
端點的第一種方法是推薦的方法,但是,它涉及額外的 API 調用,大多數情況下第二種方法應該可以正常工作。
混合方法是按照方法 2 構造 URL,然后如果方法 2 返回 404 或其他錯誤,則回退到方法 1。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.