Cannot get aws lambda function response in PHP client
Oh! well, I found the answer.
You need to call the __toString()
method of the GuzzleHttp\Psr7\Stream
Object that is inside the Payload
.
So, doing a print_r($response['Payload']->__toString());
prints "Success" which is the desired response of the Lambda function, and the one that I was looking for.
Hope this helps someone in the future.
Another way is to call, getContents()
of the stream object as following:
$result = $client->invoke(array(
// FunctionName is required
'FunctionName' => 'myService-beta-hello',
'InvocationType' => 'RequestResponse',
'LogType' => 'Tail',
'Payload' => '{"key1":"value1", "key2":"value2","key3":"value3"}',
//'Qualifier' => 'string',
));
print "<pre>";
print_r($result);
print_r($result['Payload']->getContents());
print "</pre>";