我使用SoftLayer API PHP库来调用SoftLayer_billing_Item.cancelItem(...)或SoftLayer_billing_Item.cancelService()来取消该项目。我注意到在SoftLayer_billing_Item.cancelItem(...)或SoftLayer_billing_Item.cancelService()调用之后,SoftLayer客户门户上将生成SoftLayer票证。
SoftLayer_billing_Item.cancelItem(...)或SoftLayer_billing_Item.cancelService()的API返回结果不包含SoftLayer_Ticket结果信息。
如何使用API获取与SoftLayer_billing_Item.cancelItem(...)或SoftLayer_billing_Item.cancelService()相关联的SoftLayer_Ticket Id值。
我可以使用相同的php文件吗?
答案 0 :(得分:0)
您可以在代码中使用下一个objectMask:
<?php
// Reference to the SL API client (It depends on your path installation)
require_once ('C:\softlayer-api-php-client-master\src\SoapClient.php');
require_once ('C:\softlayer-api-php-client-master\src\Common\ObjectMask.php');
// Set these values with your valid information.
$username = 'set me';
$apiKey = 'set me';
$service = 'SoftLayer_Billing_Item';
// Set your billing item Id.
$billingItemId = 7883593;
// The client instantiation.
$client = \SoftLayer\SoapClient::getClient($service, $billingItemId, $username, $apiKey);
// The next lines belong to the creation of an object mask that retrieves aditional data
// contained in the objects retrieved.
$objectMask = new \SoftLayer\Common\ObjectMask();
$objectMask->cancellationRequests->ticket;
$client->setObjectMask($objectMask);
try
{
// Retrieving the configuration options for a SoftLayer_Hardware object.
$cancellation_request = $client->getCancellationRequests();
print_r($cancellation_request);
}
catch (\Exception $e)
{
// Displaying if an error happened.
die('Script failed, review the next message for further details: ' . $e->getMessage());
}
对于SoftLayer_Account :: getLastCanceledBillingItem或SoftLayer :: getLastCancelledServerBillingItem
等方法,您可以以相同的方式使用相同的objectMask