Created
October 5, 2013 07:50
-
-
Save hagino3000/6838047 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
# -*- coding: utf-8 -*- | |
import boto.sns | |
AWS_ACCESS_KEY = 'xxxx' | |
AWS_SECRET_ACCESS_KEY = 'yyyyyyyy' | |
APPLICATION_ARN = 'arn:aws:sns:ap-northeast-1:0000:app/APNS_SANDBOX/aaaa' | |
# SNSに接続 | |
sns_connection = boto.sns.connect_to_region('ap-northeast-1', | |
aws_access_key_id=AWS_ACCESS_KEY, | |
aws_secret_access_key=AWS_SECRET_ACCESS_KEY) | |
# 送信先デバイスを指定してendpointを作成 | |
endpoint_response = sns_connection.create_platform_endpoint( | |
platform_application_arn=APPLICATION_ARN, | |
token='xxxxxxxx') | |
endpoint = endpoint_response.get('CreatePlatformEndpointResponse').get('CreatePlatformEndpointResult').get('EndpointArn') | |
# endpointに送信 | |
sns_connection.publish(target_arn=endpoint, message=u"Hello World to endpoint") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment