首先是较旧的 FaxOut API,然后是较新的 RingCentral Platform API Message-Fax 资源。后者是我要在这里解决的问题,如果您使用的是前一个版本,请使用 RingCentral 创建一个支持案例以获得帮助。
不太好的消息是,没有直接的方法使用推送通知(订阅)来接收您正在寻找的特定传真状态数据,但是可以监控消息存储事件,并过滤 EVENT_DATA.changes 的传入数据.type === '传真'。
了解如何message-store
在订阅中使用 eventFilter:https ://developers.ringcentral.com/api-docs/latest/index.html#!#RefGetMessageEvent
此外,我在 Node.js 中创建了一个演示应用程序,向开发人员展示如何创建订阅(它使用您在问题中引用的 JavaScript SDK):
https ://github.com/bdeanindy/ringcentral-subscription-basics (有配置您可以在.env
文件中设置的参数来指示要使用的事件过滤器)。
这是我从 RingCentral 向外发送传真时的订阅事件流。注意事件过滤器,其中之一是订阅,message-store
其中传真消息可供使用 API 的开发人员使用(我在事件的每个阶段上方添加了简单的注释):
Succesfully logged into the RC Account
EVENT FILTERS: [ '/account/~/extension/2557490012',
'/account/~/extension/2557490012/presence?detailedTelephonyState=true&aggregated=true',
'/account/~/extension/2557490012/message-store',
'/account/~/extension/2557490012/presence/line',
'/account/~/extension/2557490012/message-store/instant?type=SMS' ]
SUBSCRIPTION CREATED SUCCESSFULLY
Fax Sent
SUBSCRIPTION NOTIFICATION.....
{ uuid: '8004a0b2-7907-458b-8a9b-ec1ba3202f5e',
event: '/restapi/v1.0/account/2557490012/extension/2557490012/message-store',
timestamp: '2016-09-30T22:43:53.762Z',
subscriptionId: 'bd6a307b-a05f-4421-acc5-85f093aae2b3',
body:
{ extensionId: 2557490012,
lastUpdated: '2016-09-30T22:43:43.902+0000',
changes: [ { type: 'Fax', newCount: 1, updatedCount: 0 }, [length]: 1 ] } }
Waiting to connect
SUBSCRIPTION NOTIFICATION.....
{ uuid: '627d3cdf-1638-4029-9e0b-94bbf3325c61',
event: '/restapi/v1.0/account/2557490012/extension/2557490012/message-store',
timestamp: '2016-09-30T22:44:13.776Z',
subscriptionId: 'bd6a307b-a05f-4421-acc5-85f093aae2b3',
body:
{ extensionId: 2557490012,
lastUpdated: '2016-09-30T22:44:01.879+0000',
changes: [ { type: 'Fax', newCount: 0, updatedCount: 1 }, [length]: 1 ] } }
SUBSCRIPTION NOTIFICATION.....
{ uuid: 'f1e1310e-11c7-479d-b988-087379bdcad3',
event: '/restapi/v1.0/account/2557490012/extension/2557490012/message-store',
timestamp: '2016-09-30T22:44:23.769Z',
subscriptionId: 'bd6a307b-a05f-4421-acc5-85f093aae2b3',
body:
{ extensionId: 2557490012,
lastUpdated: '2016-09-30T22:44:15.565+0000',
changes: [ { type: 'Fax', newCount: 0, updatedCount: 1 }, [length]: 1 ] } }
Waiting to have sent confirmation
SUBSCRIPTION NOTIFICATION.....
{ uuid: '2148d2d9-8e05-4adc-8019-518774187116',
event: '/restapi/v1.0/account/2557490012/extension/2557490012/message-store',
timestamp: '2016-09-30T22:45:33.767Z',
subscriptionId: 'bd6a307b-a05f-4421-acc5-85f093aae2b3',
body:
{ extensionId: 2557490012,
lastUpdated: '2016-09-30T22:45:21.232+0000',
changes: [ { type: 'Fax', newCount: 0, updatedCount: 1 }, [length]: 1 ] } }
但是,您如何确定传真是否已发送、是否已排队或已失败?您使用 EVENT.event 属性在查询中获取消息存储列表过滤: messageType=Fax&availability=Alive&direction=Outbound&messageStatus=Sent
然后,生成的消息存储记录中将有一个新项目,records
您可以使用 to.phoneNumber 来匹配发起事件(HTTP POST 发送传真)。
{
"uri": "{{REMOVED_FOR_SECURITY}}",
"id": {{REMOVED_FOR_SECURITY}},
"to": [
{
"phoneNumber": "+{{REMOVED_TO_PREVENT_SPAM}}",
"name": "Hello Fax",
"messageStatus": "Sent"
}
],
"type": "Fax",
"creationTime": "2016-09-30T22:43:43.000Z",
"readStatus": "Unread",
"priority": "Normal",
"attachments": [
{
"id": {{REMOVED_FOR_SECURITY}},
"uri": "{{REMOVED_FOR_SECURITY}}",
"type": "RenderedDocument",
"contentType": "application/pdf"
}
],
"direction": "Outbound",
"availability": "Alive",
"messageStatus": "Sent",
"faxResolution": "High",
"faxPageCount": 2,
"lastModifiedTime": "2016-09-30T22:45:21.232Z",
"coverIndex": 0
}