--- title: "GetServerCost.php" description: "GetServerCost.php" date: "2017-11-23" classes: - "SoftLayer_Account" - "SoftLayer_Hardware_Server" - "SoftLayer_ObjectMask" tags: - "billing" --- ```php */ require_once ('C:/scripst/getdetails/SoftLayer/SoapClient.class.php'); // Your SoftLayer API username and key. $apiUsername = 'set me'; $apiKey = 'set me'; /** * Method one: Getting the cost for every server on your account. * * Create a connection to the SoftLayer_Account API service and call the * getHardware() method to get a list of hardware on our account. Put an object * mask in the API call to retrieve the cost associated with hardware to get * every server's cost along with our hardware records. */ $client = Softlayer_SoapClient::getClient('SoftLayer_Account', null, $apiUsername, $apiKey); // Adding the object mask to the call. $objectMask = new SoftLayer_ObjectMask(); $objectMask->hardware->cost; $client->setObjectMask($objectMask); try { // Retrieving our account's hardware records. $hardware = $client->getHardware(); print_r($hardware); } catch (Exception $e) { die('Unable to retrieve hardware list: ' . $e->getMessage()); } ?> ```