0

我尝试使用对象过滤器来获取有效设备:

下面是php代码:

$client= SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $username, $apiKey);

    $filter = new stdClass();
    $filter->applicationDeliveryControllers = new stdClass();
    $filter->applicationDeliveryControllers->billingItem = new stdClass();
    $filter->applicationDeliveryControllers->billingItem->id = new stdClass();
    $filter->applicationDeliveryControllers->billingItem->id->operation = new stdClass();
    $filter->applicationDeliveryControllers->billingItem->id->operation = $bId;

    $client->setObjectFilter($filter);  

    try {
          $mask ='mask[id, name]';
            $client->setObjectMask($mask);
        $myInstance = $clientNetscaler->getApplicationDeliveryControllers();

    } catch(exception $ex) {

    } 

我在运行时环境中收到以下错误:

查询 SoftLayer API 时出错:函数(“setObjectFilter”)不是此服务的有效方法

错误来自行$client->setObjectFilter($filter);

有人知道为什么会出现这样的错误吗?

4

1 回答 1

0

对我来说,过滤器工作正常。以防万一,我复制了我的代码。请确保您拥有 PHP 5.2.3 或更高版本以及 SOAP 的 PHP 扩展。也尝试重新下载 Softlayer PHP 客户端https://github.com/softlayer/softlayer-api-php-client并重试。

问候

<?php
 require_once ('/SoapClient.class.php');
 $apiUsername = 'set me';
$apiKey = 'set me';

$accountService = Softlayer_SoapClient::getClient('SoftLayer_Account', null,$apiUsername, $apiKey);
$bId = 51774239;
$filter = new stdClass();
$filter->applicationDeliveryControllers = new stdClass();
$filter->applicationDeliveryControllers->billingItem = new stdClass();
$filter->applicationDeliveryControllers->billingItem->id = new stdClass();
$filter->applicationDeliveryControllers->billingItem->id->operation = new     stdClass();
$filter->applicationDeliveryControllers->billingItem->id->operation = $bId;
$accountService->setObjectFilter($filter);  
$mask ='mask[id, name]';
$accountService->setObjectMask($mask);
try {
    $myInstance  = $accountService->getApplicationDeliveryControllers();
    print_r($myInstance);
} catch (Exception $e) {
    die('Unable to executre the request. ' . $e->getMessage());
}
于 2015-11-17T16:26:07.470 回答