简体   繁体   中英

AWS-PHP-SDK / SNS direct addressing returns error

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?

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM