1

使用 SoftLayer API,我订购了 Endurance Block Storage,它就在那里。现在我正在尝试编写一个使用 SoftLayer API 来修改快照空间的 PHP 代码,但我不断收到此错误:

There was an error querying the SoftLayer API: Price does not have an id.

而且我不确定问题是什么。下面是我用来执行此操作的一些代码:

$clientServer = SoftLayer_XmlrpcClient::getClient('SoftLayer_Product_Order', null, userID, apiKey);
$clientServer->verifyOrder($order);

据我所知,我传递的 $order 低于并且传递的价格 ID 是正确的。那么我错过了什么?还是我需要以不同的方式做到这一点?

{
   "categoryCode" : "storage_snapshot_space",
   "complexType" : "Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
   "packageId" : 240,
   "prices" : [
      {
         "id" : 144295
      }
   ],
   "properties" : [
      {
         "name" : "orderOrigin",
         "value" : "control"
      }
   ],
   "virtualGuests" : null
}

任何帮助将不胜感激。谢谢你。

4

1 回答 1

1

Json 应该是这样的,其中 volumeId 是将应用升级的块存储 ID。

{
  "complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
  "packageId": 240,
  "prices": [{

    "id": 144295
  }],

  "volumeId": 5805095
}

在 PHP 中它会是这样的:

<?php

require_once ('C:/scripst/getdetails/SoftLayer/SoapClient.class.php');

$username = 'set me';
$key = 'set me';


$softLayer_product_order = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $username, $key);


$prices = array
(
    46150
);


$orderPrices = array();

foreach ($prices as $priceId){
    $price = new stdClass();
    $price->id = $priceId;
    $orderPrices[] = $price;
}

$packageId = 240;

$volumeId = 5805095;

$orderContainer = new stdClass();
$orderContainer->packageId          = $packageId;
$orderContainer->prices             = $orderPrices;
$orderContainer->volumeId           = $volumeId;

try {

    $orderTemplate = new SoapVar
    (
        $orderContainer,
        SOAP_ENC_OBJECT,
        'SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade',
        'http://api.service.softlayer.com/soap/v3/'
    );

    $receipt = $softLayer_product_order->verifyOrder($orderTemplate);
    print_r($receipt);
} catch (Exception $e) {
    echo 'Unable to place the order: ' . $e->getMessage();
}

不要忘记替换价格和volumeID

问候

于 2015-12-07T13:16:14.573 回答