我在调用SNS服务器时遇到SNS端点被禁用的问题。为了调试,我添加了日志。在日志中,它显示为true,在Amazon SNS中显示为false。请帮我解决一下情况
以下是我为设置端点Atrributes而编写的代码。
$enable_end_point = $client->setEndpointAttributes(array(
'Endpoenter code hereintArn' => $pushlist[$i]['aws'],
'Attributes' => array(
'Enabled' => 'true'
)`enter code here`
));
我从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
)
)
)
发布通知
$result = $client->publish(array(
'TargetArn' => $pushlist[$i]['aws'],
'Message' => $msg_json,
'Subject' => 'New xxxxx',
'MessageStructure' => 'json',
));
发布日志:
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
)
)
)
发布后我通过日志检查端点状态
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
)
)
)
在上面的响应中,我将端点状态设置为true。但我没有得到任何推送通知,并且在Amazon SNS状态显示为错误。
此致
Vamsi
答案 0 :(得分:1)
我认为你发送的属性为Enabled as true,
$enable_end_point = $client->setEndpointAttributes(array(
'Endpoenter code hereintArn' => $pushlist[$i]['aws'],
'Attributes' => array(
'Enabled' => 'true'
)
));
您在日志中获得的结果为真,AWS SNS应用程序中的实际值为false。
请尝试此操作以查找arn enabled状态为false或true。
$endpointAtt = $sns->getEndpointAttributes($arn_arr);
Log::info($endpointAtt['Attributes']);
if($endpointAtt != 'failed' && $endpointAtt['Attributes']['Enabled'] != 'false') {
// Code here
}