Reputation: 48
Trying to subscribe to Amazon SNS via the SDK. Currently, I can createTopic via the SDK but when trying to subscribe to an endpoint the result is an XML parser error. It seems that everything I'm doing is correct yet nothing works.
The code
`/* createTopic working, populates $topic with TopicArn correctly */
$topic = $result['TopicArn'];
$protocol = 'https';
$endpoint = 'https://oursytem.domain.com/api/endpoint'
try {
$result = $SnSclient->subscribe([
'Protocol' => $protocol,
'Endpoint' => $endpoint,
'ReturnSubscriptionArn' => true,
'TopicArn' => $topic,
]);
echo '<pre>';
print_r($result);
} catch (AwsException $e) {
// output error message if fails
error_log($e->getMessage());
}`
The trace:
`TraceMiddleware.php:268:
array (size=6)
'instance' =\> string '00000000503a6f0b000000003c8b00da' (length=32)
'class' =\> string 'Aws\\Api\\Parser\\Exception\\ParserException' (length=40)
'message' =\> string 'Error parsing XML: String could not be parsed as XML' (length=52)
'file' =\> string 'C:\\wamp64\\www\\awstest\\vendor\\aws\\aws-sdk-php\\src\\Api\\Parser\\PayloadParserTrait.php' (length=82)
'line' =\> int 49
'trace' =\> string '#0 C:\\wamp64\\www\\awstest\\vendor\\aws\\aws-sdk-php\\src\\Api\\Parser\\QueryParser.php(43): Aws\\Api\\Parser\\QueryParser->parseXml(Object(GuzzleHttp\\Psr7\\Stream), Object(GuzzleHttp\\Psr7\\Response))
`
Any thoughts? Already read a lot of docs and nothing seems to fit.
Regards.
Upvotes: 0
Views: 334
Reputation: 26
This is a known bug in the SDK: https://github.com/aws/aws-sdk-php/issues/2572.
This should be resolved in 3.246.1
.
Upvotes: 1