Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 boto3发布消息SNS_Python 2.7_Amazon Sns_Boto3 - Fatal编程技术网

Python 2.7 boto3发布消息SNS

Python 2.7 boto3发布消息SNS,python-2.7,amazon-sns,boto3,Python 2.7,Amazon Sns,Boto3,我想我正在尝试做一些非常简单的事情,但我在某些方面做错了什么,或者遗漏了什么 目标:使用boto3(aws sdk库)从python 2.7发送消息 我有应用程序密钥、注册ID等,我的代码是 response = client.publish( TargetArn=platform_endpoint['EndpointArn'], Message="Hi there" ) 然后我收到

我想我正在尝试做一些非常简单的事情,但我在某些方面做错了什么,或者遗漏了什么

目标:使用boto3(aws sdk库)从python 2.7发送消息

我有应用程序密钥、注册ID等,我的代码是

response = client.publish(
                    TargetArn=platform_endpoint['EndpointArn'],
                    Message="Hi there"
                )
然后我收到来自aws的messageId,以及终端movil中的通知弹出窗口,但始终为空,在本例中没有任何文本“Hi there”。我尝试使用aws SNS控制台并正常工作,手机正常接收文本通知

我还尝试发送一个JSON,但结果是一样的,如果最简单的目标失败了…最好用JSON:p解决这个问题


欢迎任何建议

最后,解决方案是使用json.dumps将json转换为字符串

response = client.publish(
                TargetArn=platform_endpoint['EndpointArn'],
                Message=json.dumps(jsonObj),
                MessageStructure='json'
            )