Skip to content

Instantly share code, notes, and snippets.

@toastdriven
Created September 5, 2013 23:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toastdriven/6457559 to your computer and use it in GitHub Desktop.
Save toastdriven/6457559 to your computer and use it in GitHub Desktop.
"""
When I run this (vs. the Java SNS example), I get nearly identical bodies being submitted.
The only difference is the URL-escaping, the Javas serialization for JSON strips out spaces
& Boto adds a ``ContentType=JSON`` key, which the service accepts.
Verification this works on Android would be appreciated.
"""
import json
import os
import boto
boto.set_stream_logger('boto', 'DEBUG')
c = boto.connect_sns()
msg = {
"default": "This is the default message",
"GCM": json.dumps({
"delay_while_idle": True,
"time_to_live": 125,
"dry_run": False,
"collapse_key": "Welcome",
"data": {
"message": "Hello World!",
},
})
}
res = c.publish(
message=json.dumps(msg),
message_structure='json',
target_arn='arn:*:whatever'
)
print('res=%s' % res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment