Created
September 5, 2013 23:19
-
-
Save toastdriven/6457559 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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