有人可以提供使用 SoftLayer API 订购以下安全产品的 PHP 示例:
SSL证书
硬件防火墙(到设备和 VLAN)
FortiGate Seucirty 应用程序(到 VLAN)
安全软件
要在设备上订购安全软件,客户门户会检查是否有任何符合条件的设备。什么样的设备有资格获得安全软件?我可以使用什么 SoftLayer API 来查找那些符合条件的设备?
谢谢你。
有人可以提供使用 SoftLayer API 订购以下安全产品的 PHP 示例:
SSL证书
硬件防火墙(到设备和 VLAN)
FortiGate Seucirty 应用程序(到 VLAN)
安全软件
要在设备上订购安全软件,客户门户会检查是否有任何符合条件的设备。什么样的设备有资格获得安全软件?我可以使用什么 SoftLayer API 来查找那些符合条件的设备?
谢谢你。
我希望这些 php 脚本可以帮助你:
订购 SSL 证书
<?php
/**
* Order SSL certificate
*
* This script orders a SSL Certificate
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Security_Certificate
*
* @license <http://sldn.softlayer.com/wiki/index.php/license>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once "C:/PhpSoftLayer/SoftLayer/SoftLayer/XmlrpcClient.class.php";
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
// Create a SoftLayer API client object for "SoftLayer_Product_Order" services
$productService = Softlayer_XmlrpcClient::getClient("SoftLayer_Product_Order", null, $username, $apiKey);
/**
* Define SSL Certificates Properties
* @var int $quantity
* @var int $packageId
* @var int $serverCount
* @var int $validityMonths
* @var string $orderApproverEmailAddress
* @var string $serverType
*/
$quantity = 1;
$packageId = 210;
$serverCount = 1;
$validityMonths = 24;
$serverType = "apache2";
$orderApproverEmailAddress = "admin@rubtest.com";
/**
* Build a skeleton SoftLayer_Container_Product_Order_Attribute_Contact object for administrativeContact,
* billingContact, technicalContact and organizationInformation properties. You can use the same information
* for all of these properties, or you can create this object for each one.
* @var string addressLine1
* @var string city
* @var string countryCode
* @var string postalCode
* @var string state
* @var string email
* @var string firstName
* @var string lastName
* @var string organizationName
* @var string phoneNumber
* @var string title
*/
$addressInfo = new stdClass();
$addressInfo -> address = new stdClass();
$addressInfo -> address -> addressLine1 = "Simon Lopez Av.";
$addressInfo -> address -> city = "Cochabamba";
$addressInfo -> address -> countryCode = "BO";
$addressInfo -> address -> postalCode = "0591";
$addressInfo -> address -> state = "OT";
$addressInfo -> emailAddress = "noreply@softlayer.com";
$addressInfo -> firstName = "Ruber";
$addressInfo -> lastName = "Cuellar";
$addressInfo -> organizationName = "TestCompany";
$addressInfo -> phoneNumber = "7036659886";
$addressInfo -> title = "TitleTest";
/**
* Define a collection of SoftLayer_Product_Item_Price objects. You can verify the item available for a given package using
* SoftLayer_Product_Package::getItemPrices method
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getItemPrices
*/
$price = new stdClass();
$price->id = 1836;
/**
* Declare the CSR
* @var string
*/
$certificateSigningRequest = "-----BEGIN CERTIFICATE REQUEST-----
MIIC8TCCAdkCAQAwgasxCzAJBgNVBAYTAkNaMR8wHQYDVQQIExZDemVjaCBSZXB1
YmxpYywgRXVyb3BlMRQwEgYDVQQHEwtQcmFndWUgQ2l0eTEWMBQGA1UEChMNTXkg
VW5saW1pbnRlZDEMMAoGA1UECxMDVlBOMRQwEgYDVQQDEwtydWJ0ZXN0LmNvbTEp
MCcGCSqGSIb3DQEJARYacnViZXIuY3VlbGxhckBqYWxhc29mdC5jb20wggEiMA0G
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDnusRc9LDjfm21A/fz1UhuMoUqkeji
BX/oTXsD/GmRaraOb0QnzjGoaM2K07nMENpQiJRpmEj3tEKwAXNitlapLwlXFvB7
rVd9lkvGmCIEkkDp5nbsdejS7BqJ8ikgEI+HATmdoyi9jxWrM/i6c9pnhF4j9ejI
XQnxd3yvpuxgybF3tN+HOOpXwVH4FQC7x/FRRai8jNxd2f+VzW7EgtIYxgl3L8gr
4DPPAAiX07lEAccEEUhQ3/LbTlSPiT0hiGh8tMcImYFDDyGOIRJKXSptuvYgwHRC
67D6fzT4ITtG2XMkzo5kgyZtwemRiikAzVbmtEFKwht0j0Q+3nf1Yv2BAgMBAAGg
ADANBgkqhkiG9w0BAQUFAAOCAQEAJCRjsdmVhcM+mKbG8NE4YdDyBfKvC03g/mCn
wWZWca1uRbYeJUNH2/LFy9tQ/8J07Cx0KcPmRnHbXkZaSMHsorv4sg6M3XDRaIiu
D/ltOZYlGYC1zFVM+pgiQd84krO0lTf/NiJxyyL3e3owO91h07jPuGGFygSOeKZa
cMMNdLQlPfZIS+hwZUuJSgormGhr+dfPkHbjP3l3X+uO59VNE+1zHTctCqooyCRa
HrHFjNbVD4Ou7Ff6B0LUiw9I54jH69MrtxdrsF+kvOaa44fN1NjqlM1sI4ZQs0O1
15B5NKrFMxG+5BrZYL7n8qEzra7WYFVrebjKexQqSBi4B6XU+g==
-----END CERTIFICATE REQUEST-----";
/*
* Build a skeleton SoftLayer_Container_Product_Order object with details required to order
*/
$container = new stdClass();
$container -> complexType = "SoftLayer_Container_Product_Order_Security_Certificate";
$container -> packageId = $packageId;
$container -> quantity = $quantity;
$container -> serverCount = $serverCount;
$container -> serverType = $serverType;
$container -> prices = array($price);
$container -> certificateSigningRequest = $certificateSigningRequest;
$container -> validityMonths = $validityMonths;
$container -> orderApproverEmailAddress = $orderApproverEmailAddress;
// technicalContact, administrativeContact, organizationInformation and billingContact
$container -> technicalContact = $addressInfo;
$container -> administrativeContact = $addressInfo;
$container -> organizationInformation = $addressInfo;
$container -> billingContact = $addressInfo;
$order = new stdClass();
$order->orderContainers = array();
$order->orderContainers[0] = $container;
try {
/*
* SoftLayer_Product_Order::verifyOrder() method will check your order for errors. Replace this with a call
* to placeOrder() when you're ready to order. Both calls return a receipt object that you can use for your
* records.
*/
$result = $productService -> verifyOrder($order);
print_r($result);
} catch(Exception $e) {
echo "Unable to order SSL Certificates: " . $e -> getMessage();
}
订购防火墙设备
<?php
/**
* Order dedicated Firewall for a Device (Virtual Guest)
* Important manual pages:
* http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Network_Protection_Firewall_Dedicated
* http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
* http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
* http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
*
* License <http://sldn.softlayer.com/article/License>
* Author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once "C:/PhpSoftLayer/SoftLayer/SoftLayer/SoapClient.class.php";
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
// Define the virtual guest Id that you wish to add the firewall
$virtualGuestId = 5074554;
// Creating a SoftLayer API client object
$softLayerProductOrder = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $username, $apiKey);
/**
* Building a skeleton SoftLayer_Product_Item_Price objects. These objects contain
* much more than ids, but SoftLayer's ordering system only needs the price's id
* to know what you want to order.
* to get the list of valid prices for the package
* use the SoftLayer_Product_Package:getItems method
*/
$prices = array
(
409, # Price to 100Mbps Hardware Firewall
);
/**
* Convert our item list into an array of skeleton
* SoftLayer_Product_Item_Price objects.
*/
$orderPrices = array();
foreach ($prices as $priceId){
$price = new stdClass();
$price->id = $priceId;
$orderPrices[] = $price;
}
// Define location, packageId and quantity
$location = "AMSTERDAM";
$packageId = 0; // The package Id for order monitoring packages is 0
$quantity = 1;
// Build a skeleton SoftLayer_Virtual_Guest object to model the id
// of the virtual guest where you want add the monitoring package
$virtualGuests = new stdClass();
$virtualGuests->id = $virtualGuestId;
$orderVirtualGuest = array
(
$virtualGuests
);
// Build a SoftLayer_Container_Product_Order_Network_Protection_Firewall_Dedicated object containing
// the order you wish to place.
$orderContainer = new stdClass();
$orderContainer->location = $location;
$orderContainer->packageId = $packageId;
$orderContainer->prices = $orderPrices;
$orderContainer->quantity = $quantity;
$orderContainer->virtualGuests = $orderVirtualGuest;
try {
// Re-declare the order template as a SOAP variable, so the SoftLayer
// ordering system knows what type of order you're placing.
$orderTemplate = new SoapVar
(
$orderContainer,
SOAP_ENC_OBJECT,
'SoftLayer_Container_Product_Order_Network_Protection_Firewall',
'http://api.service.softlayer.com/soap/v3.1/'
);
/*
* SoftLayer_Product_Order::verifyOrder() method will check your order for errors. Replace this with a call
* to placeOrder() when you're ready to order. Both calls return a receipt object that you can use for your
* records.
*/
$receipt = $softLayerProductOrder->verifyOrder($orderTemplate);
print_r($receipt);
} catch (Exception $e) {
echo 'Unable to order the firewall for device: ' . $e->getMessage();
}
VLAN 防火墙
<?php
/**
* Order Firewall for a VLAN
* Important manual pages:
* http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Network_Protection_Firewall_Dedicated
* http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
* http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
* http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
*
* License <http://sldn.softlayer.com/article/License>
* Author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once "C:/PhpSoftLayer/SoftLayer/SoftLayer/SoapClient.class.php";
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
// Create a SoftLayer API client object for "SoftLayer_Product_Order" services
$softLayerProductOrder = Softlayer_SoapClient::getClient("SoftLayer_Product_Order", null, $username, $apiKey);
// Declare the vlan id that you wish to add the firewall
$vlanId = 765032;
/**
* Building a skeleton SoftLayer_Product_Item_Price objects. These objects contain
* much more than ids, but SoftLayer's ordering system only needs the price's id
* to know what you want to order.
* to get the list of valid prices for the package
* use the SoftLayer_Product_Package:getItemPrices method
*/
$prices = array
(
2390, // Hardware Firewall (Dedicated)
//21514, FortiGate Security Appliance
);
/**
* Convert our item list into an array of skeleton
* SoftLayer_Product_Item_Price objects.
*/
$orderPrices = array();
foreach ($prices as $priceId){
$price = new stdClass();
$price->id = $priceId;
$orderPrices[] = $price;
}
// Declare the location, packageId and quantity
$location = "AMSTERDAM";
$packageId = 0; // The package Id for order Firewalls
$quantity = 1;
// Build a SoftLayer_Container_Product_Order_Network_Protection_Firewall_Dedicated object containing
// the order you wish to place.
$orderContainer = new stdClass();
$orderContainer->location = $location;
$orderContainer->packageId = $packageId;
$orderContainer->prices = $orderPrices;
$orderContainer->quantity = $quantity;
$orderContainer-> vlanId = $vlanId;
try {
// Re-declare the order template as a SOAP variable, so the SoftLayer
// ordering system knows what type of order you're placing.
$orderTemplate = new SoapVar
(
$orderContainer,
SOAP_ENC_OBJECT,
'SoftLayer_Container_Product_Order_Network_Protection_Firewall_Dedicated',
'http://api.service.softlayer.com/soap/v3/'
);
/*
* SoftLayer_Product_Order::verifyOrder() method will check your order for errors. Replace this with a call
* to placeOrder() when you're ready to order. Both calls return a receipt object that you can use for your
* records.
*/
$receipt = $softLayerProductOrder->verifyOrder($orderTemplate);
print_r($receipt);
} catch (Exception $e) {
echo 'Unable to place the order: ' . $e->getMessage();
}
订购安全软件(防病毒)
<?php
/**
* Purchase an Anti-virus for a server
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Ticket
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createUpgradeTicket
*
* @license <http://sldn.softlayer.com/wiki/index.php/license>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once "C:/PhpSoftLayer/SoftLayer/SoftLayer/SoapClient.class.php";
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
/**
* Define the hardware id where you wish to add the McAfee ANtivirus
* @var int $attachmentId
*/
$attachmentId = 251708;
// Define a brief description of what you wish to upgrade
$genericUpgrade = "Add / Upgrade Software";
//
$upgradeMaintenanceWindow = "9.30.2015 (Wed) 01:00(GMT-0600) - 04:00(GMT-0600)";
// Declare a detailed description of the server or account upgrade you wish to perform
$details ="I would like additional information on adding McAfee AntiVirus (5$.00 monthly) to my account.";
// Declare the attachmentType e.g. HARDWARE - VIRTUAL_GUEST - NONE
$attachmentType = "HARDWARE";
// Create a SoftLayer API client object for "SoftLayer_Ticket" service
$ticketService = SoftLayer_SoapClient::getClient("SoftLayer_Ticket", null, $username, $apiKey);
try {
$result = $ticketService -> createUpgradeTicket($attachmentId, $genericUpgrade, $upgradeMaintenanceWindow, $details, $attachmentType);
print_r($result);
} catch(Exception $e) {
echo "Unable to create the ticket: " . $e -> getMessage();
}
我为您创建了一些示例,希望它们对您有所帮助:)