Implemeting amazon Simple nodification service in RUBY -
am trying implement amazon sns using ruby. want create topic,delete topic,subscribe topic,publish topic.these included in following code.
#!/usr/bin/env ruby require 'rubygems' require 'aws-sdk' aws.config(:access_key_id => 'bt62w53q', :secret_access_key => '0edwg') @sns=aws::sns.new #d requirements alpha = @sns.topics.create('csc470test-alpha') @sns.topics.create('csc470test-beta') temp=gets @sns.topics.each |topic| puts topic.name if(topic.name=='csc470test-beta') topic.delete end end puts puts 'beta deleted.' puts @sns.topics.each |topic| puts topic.name end puts temp=gets puts #c requirements @sns.topics.each |topic| if(topic.name=='csc470test-alpha') subbed1=false subbed2=false subbed3=false topic.subscriptions.each |sub| if(sub.endpoint=='sn@aine.com') subbed1=true; end if(sub.endpoint=='pran@aine.com') subbed2=true; end if(sub.endpoint=='http://cloud.comtor.org/csc470logger/logger') subbed3=true; end end if(!subbed1) puts 'subscribed sika.' topic.subscribe('sn@aine.com') end if(!subbed2) puts 'subscribed prka' topic.subscribe('pran@aine.com', :json => true) end if(!subbed3) puts 'subscribed comtor site.' topic.subscribe('http://cloud.comtor.org/csc470logger/logger') end end end temp=gets puts 'topics info:' @sns.topics.each |topic| puts puts 'arn' puts topic.arn puts 'owner' puts topic.owner puts 'policy' puts topic.policy puts 'name' puts topic.display_name puts 'confirmed subscriptions:' puts topic.subscriptions. select{ |s| s.arn != 'pendingconfirmation' }. map(&:endpoint) # if(subs.confirmation_authenticated?) # puts 'arn: ' + subs.arn # puts 'endpoint: ' + subs.endpoint # puts 'protocol: ' + subs.protocol # end end puts temp=gets @sns.subscriptions.each |subs| puts "subscriptionarn: #{ subs.arn} " puts "topicarn: #{subs.topic_arn} " puts "owner: #{subs.owner_id} " puts "delivery policy: #{ subs.delivery_policy_json} " end
while running code in rails console. iam getting error
c:/programdata/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/aws-sdk-1.8.5/l ib/aws/core/client.rb:339:in `return_or_raise': request signature calcula ted not match signature provided. check aws secret access key , signing method. consult service documentation details. (aws::sns::er rors::signaturedoesnotmatch) c:/programdata/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/aw s-sdk-1.8.5/lib/aws/core/client.rb:440:in `client_request' (eval):3:in `create_topic' c:/programdata/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/aw s-sdk-1.8.5/lib/aws/sns/topic_collection.rb:24:in `create'
Comments
Post a Comment