65.9K
CodeProject 正在变化。 阅读更多。
Home

云传真和通知试用版用户快速入门指南

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0投票)

2023年6月9日

CPOL

2分钟阅读

viewsIcon

2074

本文档提供了使用OpenText的REST API提交传真、短信通知和电子邮件通知请求的说明。

通过在Plans | Developer | OpenText注册“云传真和通知开发者计划”的免费试用,获取测试帐户。

如何提交传真请求?

以下是使用基本身份验证(用户名和密码)提交传真请求的curl示例,附带一个文本文件。

curl -H "Content-Type: application/json" \
     -u "<userid:password>" \
     --data-binary "{
    \"destinations\": [
        {
            \"fax\": \"9999999999\"
        }
    ],
    \"documents\": [
        {
            \"name\": \"temp.txt\",
            \"type\": \"text\",
            \"data\": \"SGkgVGhlcmUsIFRoaXMgaXMgYSB0ZXN0IERvY3VtZW50Lg==\"
        }
    ]
}"  \
https://t2api.us.cloudmessaging.opentext.com/mra/v1/outbound/faxes

成功提交请求将返回HTTP 200响应代码以及一个作业ID。以下是一个示例响应:

{
    "job_id": "xsi-1111111111"
}

如何检查已提交传真请求的状态?

可以通过状态API或Webhook检查状态。使用Webhook,OpenText可以将传真状态推送到您的Web接收器。但是,需要使用此模式编写接收器来处理消息。请注意,传真状态模式对于Webhook和API是相同的。强烈建议使用Webhook,因为它避免了轮询状态。我们将提供一个curl示例,用于通过状态API检查状态。

curl -u "<userid:password>" \

'https://t2api.us.cloudmessaging.opentext.com/mra/v1/outbound/faxes/status?job_id=xsi-1111111111'

成功提交状态API调用将返回HTTP 200响应代码以及如下所示的详细JSON状态。作业状态和投递尝试状态确认传真已成功发送到目的地。

{
    "job_id": "xsi-1111111111",
    "entry_time": "2020-05-08T03:35:05.000Z",
    "job_state": [
        "Complete",
        "Posted"
    ],
    "deliveries": [
        {
            "fax": "1234567890",
            "delivery_attempts": [
                {
                    "state": "Sent",
                    "first_attempt": "2020-05-08T03:35:07.000Z",
                    "delivery_time": "2020-05-08T03:35:34.000Z",
                    "delivery_sec": 8,
                    "pages_delivered": 1,
                    "baud_rate": 31200,
                    "rcsid": "011919164813456"
                }
            ]
        }
    ]
}

如何提交短信通知请求,使用短信REST API?

以下是提交短信通知请求的curl命令示例。

curl -H "Content-Type: application/json" \
     -u "<userid:password>" \
     --data-binary "{
    \"destinations\": [
        {
            \"sms\": \"recipient sms address\"
        }
    ],
\"sms_text\": \"Hi There, This is a Test SMS from OpenText\"
}"  \
https://t2api.us.cloudmessaging.opentext.com/mra/v1/outbound/sms

成功提交请求将返回HTTP 200响应代码以及与上述传真示例类似的作业ID。

如何检查已提交短信请求的状态?

与获取传真状态类似,如上所述,只是需要使用以下示例代码中的短信状态URL。

curl -u "<userid:password>" \
'https://t2api.us.cloudmessaging.opentext.com/mra/v1/outbound/sms/status?job_id=xsi-2222222222'

以下是一个短信状态响应示例:

{
    "job_id": "xsi-2222222222",
    "entry_time": "2022-01-19T13:57:20.000Z",
    "job_state": [
        "Complete",
        "Posted"
    ],
    "deliveries": [
        {
            "sms": "9999999999",
            "delivery_attempts": [
                {
                    "state": "Sent",
                    "first_attempt": "2022-01-20T14: 27: 11.000Z"
                }
            ],
            "events": {
                "sms_delivery_events": [
                    {
                        "event_time": "2022-01-20T14: 27: 00.000Z",
                        "status": "Confirmed"
                    }
                ]
            }
        }
    ]
}

如何提交电子邮件通知请求,使用电子邮件REST API?

以下是提交电子邮件通知请求的curl命令示例。

curl -H "Content-Type: application/json" \
-u "<userid:password>" \
--data-binary "{
\"destinations\": [
{
	\"email\": \"recipient email address\"
}
],
\"body\": [
{
	\"name\": \"temp.txt\",
	\"type\": \"text\",
	\"charset\": \"UTF-8\",
	\"data\": \"SGkgVGhlcmUsIFRoaXMgaXMgYSB0ZXN0IERvY3VtZW50Lg==\"
}
]
}"  \
https://t2api.us.cloudmessaging.opentext.com/mra/v1/outbound/emails

成功提交请求将返回HTTP 200响应代码以及与上述传真示例类似的作业ID。

如何检查已提交电子邮件通知请求的状态?

与获取传真状态类似,如上所述,只是需要使用以下示例代码中的电子邮件状态URL。

curl -u "<userid:password>" \
'https://t2api.us.cloudmessaging.opentext.com/mra/v1/outbound/emails/status?job_id=xsi-3333333333'

以下是一个电子邮件状态响应示例:

{
    "job_id": "xsi-3333333333",
    "entry_time": "2022-01-19T14:04:14.000Z",
    "job_state": [
        "Complete",
        "Posted"
    ],
    "deliveries": [
        {
            "ref_base64": "SU5URVJORVQ=",
            "email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="">[email protected]</a>",
            "delivery_attempts": [
                {
                    "state": "Sent",
                    "first_attempt": "2022-01-19T14:15:42.000Z"
                }
            ],
            "events": {
                "email_delivery_events": [
                    {
                        "dsn": {
                            "event_time": "2022-01-19T14:05:00.000Z",
                            "value": "2.0.0",
                            "message": "\"%20smtp;250%202.0.0%20OK\""
                        }
                    }
                ]
            }
        }
    ]
}

有关模式详细信息,请参阅API文档。

© . All rights reserved.