How to make request to DirectAdmin with REST API?

ساخت وبلاگ

Bare in mind that the DA API format was made like 14 years ago; at which time the REST format was no way the standard that it is today.

Screenshot-2016-11-01-16.01.29.png
Source: https://blog.readme.io/the-history-of-rest-apis/

A very basic PHP example is this:

PHP Code:

<?php

$x 

file_get_contents('https://admin:yourpass@hostname:2222/CMD_API_SHOW_USER_USAGE?user=admin'); $y urldecode($x); parse_str($y$output); print_r($output); ?>
I just tested this; this returns an array with the info from the API.

Note:

So basically you need to make a simple http request, with basic authentication: https://en.wikipedia.org/wiki/Basic_...authentication

Then you need to decode the url, and parse it. You could search for replacement functions of urldecode and parse_str for your language; usually those are easily found in any popular language.

DirectAdmin Forums...
ما را در سایت DirectAdmin Forums دنبال می کنید

برچسب : نویسنده : ایمان اصلاحی directadmin بازدید : 372 تاريخ : پنجشنبه 29 تير 1396 ساعت: 12:14