我正在尝试使用PHP创建一个新的带宽池,但我收到有关我的API密钥的错误。如果我使用相同的键运行任何其他脚本,他们返回就好了,这让我觉得我的脚本中的某些东西导致事情无法解析:
<?php
require_once './vendor/autoload.php';
$apiUsername = getenv('SOFTLAYER_USERNAME');
$apiKey = getenv('SOFTLAYER_API_KEY');
$template = new stdClass();
$template->accountId = xxxxx;
$template->bandwidthAllotmentTypeId = 2;
$template->locationGroupId = 1;
$template->name = 'newBWpoolPHP';
$template->serviceProviderId = 1;
try {
$client = \SoftLayer\SoapClient::getClient('SoftLayer_Network_Bandwidth_Version1_Allotment', $apiUsername, $apiKey);
$response = $client->createObject(template);
print_r($response);
} catch(Exception $e) {
echo 'Cannot compute. Error is: ' . $e->getMessage();
}
?>