2016-08-14 19 views
0

PHPを使用して新しい帯域幅プールを作成しようとしていますが、私のAPIキーに関するエラーが戻ってきています。あなたは間違って作成しているにPHPで帯域幅プールを作成

<?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(); 
} 

?> 

答えて

1

エラーが原因である:私は同じキーでただし、他のスクリプトを実行した場合、彼らは私が私のスクリプトで何かが故障して解析された取得する事を引き起こしていると思わせるこれだけで結構戻りますあなたはヌルとして値を送信する必要があるので、

getClient(「serviceNameを」、オブジェクトID、ユーザ名、APIKEY)この場合、

何のオブジェクトIDが存在しない:サービスが、それには以下が必要です。

以下のコード試してみてください。

<?php 
    require_once './vendor/autoload.php'; 
    $apiUsername = getenv('SOFTLAYER_USERNAME'); 
    $apiKey = getenv('SOFTLAYER_API_KEY'); 

    $template = new stdClass(); 
    $template->accountId = 307608; 
    $template->bandwidthAllotmentTypeId = 2; 
    $template->locationGroupId = 1; 
    $template->name = 'newBWpoolPHP'; 

    try { 
     $client = \SoftLayer\SoapClient::getClient('SoftLayer_Network_Bandwidth_Version1_Allotment', null, $apiUsername, $apiKey); 
     $response = $client->createObject($template); 

     print_r($response); 

    } catch(Exception $e) { 
     echo 'Cannot compute. Error is: ' . $e->getMessage(); 
    } 

    ?> 
+0

は、完全に感謝を働きました。 – greyhoundforty

関連する問題