Get API KEY/Call API method/PHP sample code tutorial

888u

Last update at :2024-01-19,Edit by888u

The KiwiVM control panel provides an API interface, and you can call the KiwiVM API by writing your own code. This article shares the Banwagonhost API tutorial, including how to obtain the Banwagonhost API KEY (API key), how to reset the API KEY, and how to call it through code after obtaining the API KEY, including using PHP code, or directly using wget and curl and other tools to call. In fact, calling the method is very simple, just send a request and return a result.

How to obtain API KEY by Banwagonhost

The first step is to obtain the API KEY. We can obtain it directly from the API option in the left menu of the KiwiVM control panel, as shown in the figure. You can also directly export the API KEY of all VPS in batches.

The bricklayer calls the API method

After you have the API KEY and VEID, you can make the call.

Whether you want to automatically create nightly snapshots, query status of your VPS, or develop a complete replacement for the KiwiVM panel, this page is for you.

To export a csv-formatted list of API keys of all instances under your account, please use our billing portal’s CSV export feature.

All parameters can be passed either via GET or POST methods.

  • Whether you want to automate nightly snapshots, query VPS status, or develop a complete replacement for the KiwiVM panel, this page is for you.
  • To export a csv-formatted list of API keys for all instances under your account, use our billing portal's CSV export feature.
  • All parameters can be passed via GET or POST methods.

In short, just send a GET or POST request to the following address:

https://api.64clouds.com/v1/getServiceInfo?veid=YOUR_VEID_HERE&api_key=YOUR_API_KEY_HERE

Some information in the above address needs to be replaced:

  • getServiceInfo: can be replaced by other API functions. For all available interfaces, please refer to the API page of the KiwiVM control panel
  • YOUR_VEID_HERE: Replace with your VEID
  • YOUR_API_KEY_HERE: Replace with your API KEY

Each API call requires you to provide a valid combination of VEID (VPS ID) and API key, as shown in the example.

Every API call always returns an error variable. If the error is non-zero, check the "message" variable for more details about the error.

PHP sample code and return results

The following is a PHP sample code, which is more intuitive.

PHP code to get VPS information:

$request = "https://api.64clouds.com/v1/getServiceInfo?veid=YOUR_VEID_HERE&api_key=YOUR_API_KEY_HERE"; $serviceInfo = json_decode (file_get_contents ($request)); print_r ($serviceInfo);

The returned results are as follows:

/* ------------------------------- [ output ] --------------- ------------------ stdClassObject ( [hostname] => my.server.com [node_ip] => 10.20.30.40 [node_alias] => Node32 [node_location] => US, Florida [plan] => micro128 [plan_monthly_data] => 322122547200 [plan_disk] => 4294967296 [plan_ram] => 155189248 [plan_swap] => 37748736 [os] => centos-6-x86_64 [email] => customer@example.com [data_counter] => 569810827 [data_next_reset] => 1430193600 [ip_addresses] => Array ( [0] => 11.22.33.44 [1] => 11.22.33.45 ) [rdns_api_available] => 1 [ptr] => stdClassObject ( [11.22.33.44] => ns1.my.server.com [11.22.33.45] => ns2.my.server.com ) [error] => 0 ) */

This return result may not be the most comprehensive. The latest return result shall be subject to the actual return and should contain more information.

Use wget and curl to call API

In fact, you can also call the API directly using wget or curl commands. Let me share it below.

Use wget to call the API:

wget -qO- "https://api.64clouds.com/v1/restart?veid=YOUR_VEID_HERE&api_key=YOUR_API_KEY_HERE"

Use curl to call the API:

//You may want to use curl instead as it allows passing all variables in a POST request $requestData = array ("veid" => YOUR_VEID_HERE, "api_key" => "YOUR_API_KEY_HERE"); $request = "restart"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.64clouds.com/v1/$request"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // curl running on Windows has issues with SSL - // see https://kb.ucla.edu/articles/how-do-i-use-curl-in-php-on-windows curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $jsonData = curl_exec($ch); if (curl_error($ch)) die("Connection Error: ".curl_errno($ch)." - ".curl_error($ch)); curl_close($ch); print_r (json_decode ($jsonData));

curl allows all variables to be passed in the POST request, so if you may need more settings, you will use curl, otherwise we can use wget.

The above are some tutorials on how to call the Banwagonhost API. Generally speaking, it is not difficult.

Recommended discounts/cost-effective packages for bricklayers

Warm reminder: If you have difficulty choosing, just choose the CN2 GIA-E plan in the middle. The quarterly payment is $49.99, and you can switch between up to 12 computer rooms at will.

Banwagonhost discount code: BWH3HYATVBJW, discount 6.58%, available everywhere. The table below summarizes more preferential packages for bricklayer removal.

plan Memory CPU harddisk Traffic/month bandwidth engine room price Buy
CN2 (cheapest) 1GB 1 core 20GB 1TB 1Gbps DC3 CN2 DC8 ZNET $49.99/year Buy
CN2 2GB 1 core 40GB 2TB 1Gbps $52.99/half year $99.99/year Buy
CN2 GIA-E (Most recommended) 1GB 2 cores 20GB 1TB 2.5Gbps DC6 CN2 GIA-E DC9 CN2 GIA Japan SoftBank JPOS_1 China Unicom Netherlands EUNL_9 $49.99/quarter $169.99/year Buy
CN2 GIA-E 2GB 3 core 40GB 2TB 2.5Gbps $89.99/quarter $299.99/year Buy
HK 2GB 2 cores 40GB 0.5TB 1Gbps Hong Kong CN2 GIA $89.99/month $899.99/year Buy
HK 4GB 4 core 80GB 1TB 1Gbps $155.99/month $1559.99/year Buy

Select a suggestion:

  • Getting started: Los Angeles CN2 package, currently the cheapest, optional CN2 GT computer room, the entry-level choice.
  • Recommendation: Los Angeles CN2 GIA-E package, affordable, super fast, with many optional computer rooms, and the most cost-effective.
  • High-end: Hong Kong CN2 GIA package, the price is higher, but impeccable.

Recommended site searches: free asp.net space, how to bind a domain name to a server, Korean virtual host domain name price, php virtual host, domain name space proxy, Hong Kong server defense, domain name resolution query, free overseas server, Chinese domain name registration, < /p>

Get API KEY/Call API method/PHP sample code tutorial

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码