Im working out an integration with AWS Pinpoint with the AWS PHP SDK v3. In documentation for the function sendMessages there is no parameter to pass in the template ARN. Yet i get an error that demands an template ARN:
PERMANENT_FAILURE [StatusCode] => 400 [StatusMessage] => Request must include template ARN.
Currently have this function defined for sending the message:
public function sendMessage($id = null)
{
$this->autoRender = false;
$this->Authorization->skipAuthorization();
// Initialize the AWS SDK
$credentials = CredentialProvider::sso('dev-sso');
$client = new PinpointClient([
'region' => 'eu-central-1',
'credentials' => $credentials,
]);
$Message= $this->Messages->get($id, contain: []);
$templateArn = 'arn:aws:mobiletargeting:eu-central-1:xxxxxx:templates/xxxxxx/EMAIL';
$params = [
'ApplicationId' => 'xxxxxx',
'MessageRequest' => [
'Addresses' => [
'[email protected]' => [
'ChannelType' => 'EMAIL',
],
],
'MessageConfiguration' => [
'EmailMessage' => [
'FromAddress' => '[email protected]',
],
'TemplateConfiguration' => [
'EmailTemplate' => [
'Name' => $Message->id,
'TemplateArn' => $templateArn
'Version' => 'latest',
],
],
],
]
];
try {
$result = $client->sendMessages($params);
print_r($result);
} catch (AwsException $e) {
// output error message if fails
dd($e->getMessage());
}
}
I’ve tried placing the ARN in multiple positions in the parameters that would make sense, but cant seem to find anything that works. Help pls
joost0004 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.