dongqing483174 2015-11-17 15:18
浏览 40
已采纳

Softlayer API PHP错误函数(“setObjectFilter”)不是此服务的有效方法

I tried to use object filter to get valid device:

Below is the php code:

$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) {

    } 

I got the following error in my run time environment:

There was an error querying the SoftLayer API: Function ("setObjectFilter") is not a valid method for this service

The error came from line $client->setObjectFilter($filter);

Anybody has any idea of why there's such error?

  • 写回答

1条回答 默认 最新

  • doudundian9558 2015-11-17 16:26
    关注

    For me the filter is working fine. Just in case, I copied my code. Please make sure you have PHP 5.2.3 or higher and the PHP extension for SOAP. Also try re-downloading the Softlayer PHP client https://github.com/softlayer/softlayer-api-php-client and try again.

    Regards

    <?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());
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?