如何解析 S3 响应 Guzzle\Service\Resource\Model 对象?

How to parse S3 response Guzzle\Service\Resource\Model object?

请求 S3,v2 API.

$result = $client->getBucketLifecycleConfiguration(array(
    // Bucket is required
    'Bucket' => 'string',
));

我收到以下回复

Guzzle\Service\Resource\Model::__set_state(array(
   'structure' => NULL,
   'data' => 
  array (
    'Rules' => 
    array (
      0 => 
      array (
        'ID' => 'Test',
        'Filter' => 
        array (
          'Prefix' => 
          array (
          ),
        ),
        'Status' => 'Enabled',
        'NoncurrentVersionExpiration' => 
        array (
          'NoncurrentDays' => '250',
        ),
      ),
    ),
    'RequestId' => 'E83571AFC306FFFD',
  ),
))

我要解析这个对象!

尝试获取如下数据 $result->data 得到 NULL

我试图将其类型转换为 array 但得到了以下数组索引。看来我做错了。

array (
  '' . "[=13=]" . '*' . "[=13=]" . 'structure' => NULL,
  '' . "[=13=]" . '*' . "[=13=]" . 'data' => 
  array (
    'Rules' => 
    array (
      0 => 
      array (
        'ID' => 'Test',
        'Filter' => 
        array (
          'Prefix' => 
          array (
          ),
        ),
        'Status' => 'Enabled',
        'NoncurrentVersionExpiration' => 
        array (
          'NoncurrentDays' => '250',
        ),
      ),
    ),
    'RequestId' => 'E83571AFC306FFFD',
  ),
)

看看http://docs.aws.amazon.com/aws-sdk-php/v2/guide/feature-models.html

根据link,您可以使用$result->toArray()方法将模型转换为数组,或者直接通过数组键访问您想要的结果属性,即$result['Rules'].