我想通过Amazon SNS向用户发送短信。我在vb.net中编写了以下代码,但发生了错误:
“消息属性'AWS.SNS.SMS.SMSType'具有无效的消息属性类型,支持的类型前缀集为Binary,Number和String。”
我的按钮单击事件代码是:
Imports Amazon.SimpleNotificationService
Imports Amazon.SimpleNotificationService.Model
Public Class Form1
Dim myclient As New AmazonSimpleNotificationServiceClient
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim snsreq As New PublishRequest
Dim snsres As New PublishResponse
Dim snsmsgstng As New Dictionary(Of String, MessageAttributeValue)()
snsmsgstng.Add("AWS.SNS.SMS.SenderID", New MessageAttributeValue() With {.StringValue = "testing", .DataType = "string"})
snsmsgstng.Add("AWS.SNS.SMS.SMSType", New MessageAttributeValue() With {.StringValue = "Promotional", .DataType = "string"})
snsreq.MessageAttributes = snsmsgstng
snsreq.PhoneNumber = "+972543784512" 'phone No
snsreq.Message = "you get message ,if yes then tells me???.."
snsres = myclient.Publish(snsreq)
End Sub
End Class
然后在app.config文件中添加以下代码
<appSettings >
<add key="AWSAccessKey" value="MYAWSAccessKey" />
<add key="AWSSecretKey" value="MYAWSSecretKey"/>
<add key="AWSRegion" value="ap-southeast-1"/>
</appSettings>
我不知道代码在哪里。