Kev*_*ary 7 php amazon amazon-s3 amazon-web-services
我正在使用新的Amazon ElasticTranscoder服务,并且是使用AWS-SDK的新手.我创建了一个成功的脚本来运行createJob请求,将Amazon S3文件从一种格式转码到另一种格式.
问题是,我似乎无法访问$data请求发出时返回的响应.我可以看到它,它包含我需要的信息,但是当我尝试存储它时收到此错误:
Fatal error: Cannot access protected property Guzzle\Service\Resource\Model::$data
这是我的请求的样子:
<?php
// Include the SDK
require 'aws.phar';
use Aws\ElasticTranscoder\ElasticTranscoderClient;
// Setup the trancoding service tool(s)
$client = ElasticTranscoderClient::factory( array(
'key' => 'XXXXXXXXX',
'secret' => 'XXXXXXXXX',
'region' => 'us-east-1'
) );
// Create a new transcoding job
$file_name = '1362761118382-lqg0CvC1Z1.mov';
$file_name_explode = explode( '.', $file_name );
$webm_transcode_request = $client->createJob( array(
'PipelineId' => '1362759955061-7ad779',
'Input' => array(
'Key' => $file_name,
'FrameRate' => 'auto',
'Resolution' => 'auto',
'AspectRatio' => 'auto',
'Interlaced' => 'auto',
'Container' => 'auto',
),
'Output' => array(
'Key' => $file_name_explode[0] . '.webm',
'ThumbnailPattern' => $file_name_explode[0] . '-thumb-{resolution}-{count}',
'Rotate' => '0',
'PresetId' => '1363008701532-b7d529' // BenchFly MP4
)
) );
// Print the response data
echo '<pre>';
var_dump( $webm_transcode_request->data );
echo '</pre>';
?>
Run Code Online (Sandbox Code Playgroud)
我一直在试图找到一些关于使用PHP和AWS SDK处理响应请求的文档,我非常感谢任何帮助.
iPh*_*ney 19
您有两种选择:
使用toArray()方法"从继承的方法中列出Guzzle\Common\Collection的" 的文档.
例如
$webm_transcode_request->toArray();
Run Code Online (Sandbox Code Playgroud)只需直接访问$data属性的索引,就好像它们是响应对象的索引一样.这是有效的,因为Guzzle\Service\Resource\Model该类实现了PHP的魔术ArrayAccess接口,以便对$data属性进行类似数组的访问.
例如
$response = $ec2Client->describeInstances();
// Gets the value of the 'Reservations' key of the protected `$data` property
// of `$response`
var_dump($response['Reservations']);
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
2517 次 |
| 最近记录: |