使用下面的PHP代码来调用lambda函数,但我收到以下错误。看看PHP AWS api文档无法找到导致问题的原因。 从aws php sdk接收以下错误
PHP Warning: Illegal string offset 'StatusCode' in /var/www/html/Guzzle/Service/Command/LocationVisitor/Response/StatusCodeVisitor.php on line 21
PHP Warning: Illegal string offset 'FunctionError' in /var/www/html/Guzzle/Service/Command/LocationVisitor/Response/HeaderVisitor.php on line 24
PHP Warning: Illegal string offset 'LogResult' in /var/www/html/Guzzle/Service/Command/LocationVisitor/Response/HeaderVisitor.php on line 24
PHP Catchable fatal error: Argument 1 passed to Guzzle\Service\Resource\Model::__construct() must be of the type array, string given, called in /var/www/html/Guzzle/Service/Command/OperationResponseParser.php on line 86 and defined in /var/www/html/Guzzle/Service/Resource/Model.php on line 20
use Aws\Lambda\LambdaClient;
$client = LambdaClient::factory(array(
'credentials' => array(
'key' => $f_key,
'secret' => $f_secret,
),
'region' => 'ap-southeast-2'
));
try {
echo "new invoke" . "\n";
$result = $client->invoke(array(
// FunctionName is required
'FunctionName' => 'hello_wo’,
));
}catch(Exception $e) {
echo 'Error retrieving lambd error message code-' . $e->getCode . '-error message-' . $e->getMessage() ;
}
答案 0 :(得分:0)
试试这个:
$client = LambdaClient::factory([
'key' => $f_key,
'secret' => $f_secret,
'region' => 'ap-southeast-2'
]);