我有以下代码:
<?php
echo('Success');
//Setup the API
require 'vendor/autoload.php';
use Aws\Lambda\LambdaClient;
//Login to the Dynamo DB
$client = LambdaClient::factory(array(
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => array(
'key' => 'My Key',
'secret' => 'My Secret',
)
));
$rawdata = file_get_contents('php://input');
//echo("Raw Data:");
//echo($rawdata);
$client->invoke([
'FunctionName' => 'LocationUpdate',
'InvocationType' => 'Event',
'Payload' => $rawdata
]);
&#13;
当我运行代码时,没有调用类型,它工作得很好。但是,当我使用调用类型为Event或DryRun来运行它时,它不起作用,而是抛出以下错误。我做错了什么?
<b>Fatal error</b>: Uncaught Guzzle\Common\Exception\RuntimeException: Unable to parse response body into JSON: 4 in /var/www/html/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php:861
Stack trace:
#0 /var/www/html/vendor/guzzle/guzzle/src/Guzzle/Service/Command/LocationVisitor/Response/JsonVisitor.php(22): Guzzle\Http\Message\Response->json()
#1 /var/www/html/vendor/guzzle/guzzle/src/Guzzle/Service/Command/OperationResponseParser.php(134): Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor->before(Object(Guzzle\Service\Command\OperationCommand), Array)
#2 /var/www/html/vendor/guzzle/guzzle/src/Guzzle/Service/Command/OperationResponseParser.php(86): Guzzle\Service\Command\OperationResponseParser->visitResult(Object(Guzzle\Service\Description\Parameter), Object(Guzzle\Service\Command\OperationCommand), Object(Guzzle\Http\Message\Response))
#3 /var/www/html/vendor/guzzle/guzzle/src/Guzzle/Service/Command/DefaultResponseParser.php(39): Guzzle\Service\Command\OperationResponseParser->handleParsing(Object(Guzzle\Serv in <b>/var/www/html/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php</b> on line <b>861</b><br />
&#13;
答案 0 :(得分:0)
我继续下载PHAR lambda文件,而不是使用之前使用的过时技术(guzzle),它现在运行得很好。
https://github.com/aws/aws-sdk-php/releases
http://docs.aws.amazon.com/aws-sdk-php/v2/guide/installation.html