AWS-PHP-SDK / SNS direct addressing returns error

纵然是瞬间 提交于 2019-12-12 19:19:19

问题


Hi I am using Laravel 4 setup to make use of AWS SNS to send a push message to my iOS device, the publish command to my device works well from AWS console.

I then tried from PHP:

    $sns = AWS::get('sns');

    $sns->publish(array(
        'Message' => 'Hello from PHP',
        'TargetArn' => "arn:aws:sns:us-west-2:360542326270:endpoint/APNS_SANDBOX/Testtest/20a75cd1-da25-3331-8126-4db497cbdd5e"
    ));

I am getting

Guzzle \ Service \ Exception \ ValidationException Validation errors: [TopicArn] is a required string: The topic you want to publish to.

but the docs specifically say I can use publish to either send to a topic ARN or use direct addressing to send to a single device directly.

it seems the AWS PHP SDK forces me to use TopicArn anyway.

http://aws.typepad.com/aws/2013/08/push-notifications-to-mobile-devices-using-amazon-sns.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+AmazonWebServicesBlog+(Amazon+Web+Services+Blog)

what am I doing wrong?


回答1:


I just removed the explicit guzzle line from composer. then ran update, it removed guzzle 3.6 and installed 3.9. it then removed AWS-PHP-SDK 2.3.4 and installed dev-master

I then tried it and it worked.

not sure what was the problem, but different packages versions did not work together...



来源:https://stackoverflow.com/questions/23255405/aws-php-sdk-sns-direct-addressing-returns-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!