【发布时间】:2014-11-17 16:28:48
【问题描述】:
我们将 Amazon SNS 用于我们的推送通知服务。它曾经工作得很好,直到我想到在 MessageAttributes 中包含一个 TTL。基本上出于测试目的,我想将 TTL 时间保持为 60 秒。
我使用 RestClient。我不使用 Amazon SDK。
def publish(endpoint_arn, message,message_attribute)
params = {
:TargetArn => endpoint_arn,
:Message => JSON.dump(message),
:MessageStructure => 'json',
:MessageAttributes => {
message_attribute => {
:DataType => 'String',
:StringValue => '60'
}
}
}
post(:Publish, params)
end
message_attribute 是一个包含“AWS.SNS.MOBILE.GCM.TTL”的字符串
def post(command, params)
params.merge!(default_post_params(command))
params[:Signature] = calculate_signature(params, 'POST')
response = RestClient.post(SNS_URL, params)
end
上面的代码有什么问题,亚马逊文档说我所做的是正确的。
Amazon SDK API 参考:http://docs.aws.amazon.com/sns/latest/dg/sns-ttl.html
PS:default_post_params,会有一个通用的post params,比如Access Key,SNS Url。它工作正常。只有在包含 MessageAttributes 键后它才会说,
<Error>
<Type>Sender</Type>
<Code>MalformedQueryString</Code>
<Message>Keys may not contain [</Message>
</Error>
【问题讨论】:
标签: ruby-on-rails-3 amazon-web-services push-notification amazon-sns