我有一个要求,我想在设备订阅中添加数字(UNIX时间戳)过滤器策略,并在向主题发布通知时添加带有范围策略的消息属性,但我从AWS SDK获得内部服务器响应。 / p>
以下是我在向特定时间订阅的设备发布消息时所做的事情,
$filterMessageAttributes = [
"DataType" => "Binary",
"BinaryValue" => json_encode([
"numeric" => [
">=",
$filterStartUnixTime,
"<=",
$filterEndUnixTime
]
])
];
$res = $sns->publish([
'Message' => json_encode($message),
'TopicArn' => $appTopicARN,
'MessageStructure' => 'json',
'MessageAttributes' => [
"subscription_timestamp" => $filterMessageAttributes
]
]);
这很好用,但订阅设备到SNS主题和设置订阅属性可以从AWS获得500个响应代码
$res = $sns->createPlatformEndpoint([
"PlatformApplicationArn" => "<android app arn>",
"Token" => "<device token>",
"CustomUserData" => "<some user attributes>"
]);
$endPointARN = $res->get("EndpointArn");
$res = $sns->subscribe([
"TopicArn" => "<android topic arn>",
"Protocol" => "application",
"Endpoint" => $endPointARN
]);
/**
* Add unix timestamp attribute to the above subscription
*/
$sns->setSubscriptionAttributes([
// SubscriptionArn is required
'SubscriptionArn' => $res->get("SubscriptionArn"),
// AttributeName is required
'AttributeName' => 'FilterPolicy',
'AttributeValue' => json_encode([
"subscription_timestamp" => [time()]
])]);
以下是AWS的回复,
Error executing "SetSubscriptionAttributes" on "https://sns.us-west-2.amazonaws.com"; AWS HTTP error: Server error: `POST https://sns.us-west-2.amazonaws.com` resulted in a `500 Internal Server Error` response: <ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> <Error> <Type>Receiver</Type> <Code>InternalF (truncated...) InternalFailure (server): - <ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/"> <Error> <Type>Receiver</Type> <Code>InternalFailure</Code> </Error> <RequestId><REQUESTID></RequestId> </ErrorResponse>
PHP AWS SDK版本:&#34; 3.52.31&#34;