【问题标题】:php aws sdk cant invoke lambda functionphp aws sdk 无法调用 lambda 函数
【发布时间】:2017-10-03 08:59:58
【问题描述】:

使用下面的 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() ;
    }

【问题讨论】:

  • 谁能帮我解决这个问题

标签: aws-lambda aws-sdk aws-php-sdk


【解决方案1】:

试试这个:

$client = LambdaClient::factory([
        'key' => $f_key,
        'secret' => $f_secret,
        'region' => 'ap-southeast-2'
    ]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-09
    • 2020-02-24
    • 2016-10-30
    • 1970-01-01
    • 2020-02-06
    • 1970-01-01
    • 2022-01-17
    • 2021-12-09
    相关资源
    最近更新 更多