【问题标题】:Not working AWS SNS Sending Text messages using AWS SDK in C#不工作 AWS SNS 在 C# 中使用 AWS 开发工具包发送文本消息
【发布时间】:2017-03-01 01:32:54
【问题描述】:

我已在示例应用程序中使用 AWS - Amazon Simple Notification Service NuGet 包成功发送短信。 (在这个包中,它会自动安装 AWSSDK-Core 运行时) 但是,当我尝试在当前项目中合并代码时,我们已经将 AWS 开发工具包用于其他亚马逊服务,但我没有获得发送短信所需的属性之一。

对于发送短信,我们需要创建发布请求对象并将该对象传递给 AmazonSimpleNotificationServiceClient。

请看下面的代码

AmazonSimpleNotificationServiceClient smsClient = new AmazonSimpleNotificationServiceClient("Access Key", "Secret Access Key", Region);

PublishRequest publishRequest = new PublishRequest();
publishRequest.Message = message;
publishRequest.MessageAttributes = smsAttributes; 
publishRequest.PhoneNumber = "Phone number to which need to send text message";

然后,我们需要将此对象传递给 SNS

PublishResponse result = smsClient.Publish(publishRequest);

但我没有在我当前的项目中获得“PhoneNumber”属性,该属性指的是最新更新的 AWS 开发工具包(在我的项目中安装了 NuGEt 包 - 适用于 .NET 的最新版本的 AWS 开发工具包)。

如果我尝试安装已成功运行代码的早期 NuGEt 包,我会遇到冲突,因为我在两个 dll 中都获得了“AmazonSimpleNotificationServiceClient”类,即。核心和 AWSSDK。

请提出建议。

【问题讨论】:

    标签: amazon-web-services amazon-sns


    【解决方案1】:

    PhoneNumber 仍在 SDK 的最新版本中。不知何故,在您合并其他代码后,它会欺骗您的构建系统包含旧版本。在 AWSSDK.SimpleNotificationService 包的 3.1.1 版本中添加了 PhoneNumber。

    您是否向已经依赖 SDK 的项目添加了新的依赖项?

    【讨论】:

    • 因此,我添加了 AWSSDK.SimpleNotificationService 包的新引用,并为新添加的 AWS dll 提供了别名,并在我想使用 AWS SNS 服务的地方使用它们。它现在已经解决了我的问题。但是,将来,我们需要删除旧版本 2 并为每个服务安装最新的 3 版本。
    猜你喜欢
    • 2019-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 1970-01-01
    相关资源
    最近更新 更多