使用SoftLayer API,我已经订购了Endurance Block Storage,它就在那里。 现在我正在尝试编写一个PHP代码,它将使用SoftLayer API来修改快照空间,但我不断收到此错误:
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);
我传递的$订单如下,据我所知,我传递的价格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
}
任何帮助将不胜感激。谢谢。
答案 0 :(得分: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
此致