Skip to content

Instantly share code, notes, and snippets.

@hagino3000
Created October 5, 2013 07:50
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 hagino3000/6838047 to your computer and use it in GitHub Desktop.
Save hagino3000/6838047 to your computer and use it in GitHub Desktop.
# -*- 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