简体   繁体   English

在PHP中禁用Amazon SNS端点但是当我记录响应时,我将端点状态设置为已启用

[英]Amazon SNS endpoint getting disabled in php But when I log the response I am getting endpoint status as enabled

I am facing issue with SNS endpoint getting disabled when I make a call to SNS server. 我在调用SNS服务器时遇到SNS端点被禁用的问题。 For debugging I added logs. 为了调试,我添加了日志。 In logs it is showing true and in Amazon SNS it is showing false. 在日志中,它显示为true,在Amazon SNS中显示为false。 Please help me how to handle the situations 请帮我解决问题

Following is the code I am writing for setting the endpoint Atrributes. 以下是我为设置端点Atrributes而编写的代码。

$enable_end_point = $client->setEndpointAttributes(array(
    'Endpoenter code hereintArn' => $pushlist[$i]['aws'],
    'Attributes' => array(
    'Enabled' => 'true'
    )`enter code here`
));

Log response I am getting from Amazon SNS server 我从Amazon SNS服务器获取日志响应

data: get paramsGuzzle\Service\Resource\Model Object(
    [structure:protected] => 
    [data:protected] => Array
    (
        [Attributes] => Array(
            [Enabled] => true
            [Token] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        )

        [ResponseMetadata] => Array(
            [RequestId] => 1ef66366-6dc3-549a-8d38-2d4a5axxxxx
        )

    )
)

Publishing the notification 发布通知

$result = $client->publish(array(
    'TargetArn' => $pushlist[$i]['aws'],
    'Message' => $msg_json,
    'Subject' => 'New xxxxx',
    'MessageStructure' => 'json',
));

Publish log: 发布日志:

data: publish resultGuzzle\Service\Resource\Model Object
(
    [structure:protected] => 
    [data:protected] => Array
    (
        [MessageId] => 5bbeb85f-75e7-5967-a55a-f673424xxxxx
        [ResponseMetadata] => Array
        (
            [RequestId] => 5c7f3df2-ff65-5bb5-a74a-73dec8cxxxxx
        )

    )
)

After publish I am checking the endpoint status through logs 发布后,我通过日志检查端点状态

data: get params after publishGuzzle\Service\Resource\Model Object
(
    [structure:protected] => 
    [data:protected] => Array
    (
        [Attributes] => Array
        (
            [Enabled] => true
            [Token] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        )
        [ResponseMetadata] => Array
        (
            [RequestId] => f3bdbb0d-9666-5b38-84a0-f521a1cxxxxx
        )

    )
)

In the above response I am getting endpoint status as true. 在上面的响应中,我的端点状态为true。 But I am not getting any push notifications and on Amazon SNS status is showing as false. 但我没有得到任何推送通知,并且在Amazon SNS状态显示为false。

Regards, 问候,

Vamsi Vamsi

I think you were sending attributes with Enabled as true, 我认为你发送的属性为Enabled为true,

$enable_end_point = $client->setEndpointAttributes(array(
    'Endpoenter code hereintArn' => $pushlist[$i]['aws'],
    'Attributes' => array(
    'Enabled' => 'true'
    )
));

That's what you are getting as true in log and the actual is false in AWS SNS Application. 这就是您在日志中获得的结果,并且AWS SNS应用程序中的实际值为false。

Please try this one to find the arn enabled state is false or true. 请尝试这个,以找到arn启用状态为false或true。

$endpointAtt = $sns->getEndpointAttributes($arn_arr);
Log::info($endpointAtt['Attributes']);
if($endpointAtt != 'failed' && $endpointAtt['Attributes']['Enabled'] != 'false') {
   // Code here
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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