使用PHP SDK的AWS MediaLive不返回频道列表

时间:2018-03-09 01:51:55

标签: php amazon-web-services aws-sdk

我尝试使用AWS SDK for PHP和MediaLive服务。我只是想知道aws-cli命令是否正常工作

aws medialive list-channels

下面的代码是返回结果,但“频道”不返回频道列表。怎么了?

<?php
require 'vendor/autoload.php';

$client = new Aws\MediaLive\MediaLiveClient   ([
    'version'     => '2017-10-14',
    'region'      => 'ap-southeast-1',
    'debug'   => false,
    'validate' => true,
    'credentials' => [
        'key'    => '<MYKEY>',
        'secret' => '<MYSECRET>'
    ],
]);

$result = $client->listChannels();
print_r($result);

&GT;

谢谢。

1 个答案:

答案 0 :(得分:0)

下面的代码对我有用。

<?php
require 'vendor/autoload.php';
$MediaLiveClient = new MediaLiveClient([
        'version'     => 'latest',
        'region'      => 'us-east-1',
        'credentials' => [
            'key'    => '<MYKEY>',
            'secret' => '<MYSECRET>'
        ]
    ]);

$ListChannels = $MediaLiveClient->getPaginator('ListChannels');
$ChannelsArray = [];

    foreach($ListChannels as $Result){
        if (count($Result->get('Channels')) > 0){
            foreach($Result->get('Channels') as $key => $value){
                array_push($ChannelsArray, $value);
            }
        }
    }
print_r($ChannelsArray);