1

我正在使用最新的 Azure 通信 SMS 包,基本上直接复制/粘贴示例代码来尝试向我的手机发送文本。我得到了成功的 202 代码,并且可以在我设置的事件网格中成功看到该事件。但是我的手机从来没有收到短信,如果它有帮助的话 T-Mobile 是我的手机提供商,我居住在美国,拥有美国手机号码。

这是我的代码示例和敏感信息已编辑的响应

public sendSms = async (message: string, numbers: string[]) => {
    if (this.checkIfReachLimit()) {
        return;
    }
    const endpoint = `https://<resource name>.communication.azure.com`;
    const credential = new AzureKeyCredential("<cred>");
    const client = new SmsClient(endpoint, credential);
    try {
        const sendResults = await client.send(
            {
                from: "My Azure Toll Free #", // Your E.164 formatted phone number used to send SMS
                to: numbers, // The list of E.164 formatted phone numbers to which message is being sent
                message, // The message being sent
            },
            {
                enableDeliveryReport: true,
                tag: "workoutBuilder",
            },
        );
        this.updateMonthlyCount(sendResults.length);
        for (const sendResult of sendResults) {
            if (sendResult.successful) {
                console.log("Success: ", sendResult);
            } else {
                console.error("Something went wrong when trying to send this message: ", sendResult);
            }
        }
    } catch (ex) {
        // no op
    }
};

回复:

{
  to: 'my cell',
  messageId: 'message id',
  httpStatusCode: 202,
  repeatabilityResult: 'accepted',
  successful: true
}
4

0 回答 0