PDA

View Full Version : How to authenticate?



mmo
08-04-2006, 02:34 AM
I am trying to send a command to the DirectAdmin API using this code:


$diskUsage = file_get_contents('http://my_username:my_password@89.104.162.36:2222/CMD_API_SHOW_USER_USAGE?user=some_username');
echo "Disk Usage is: $diskUsage";
This is the error message I receive:
Warning: file_get_contents(http://...@89.104.162.36:2222/CMD_API_SHOW_USER_USAGE?user=some_username) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized


Note that I am using the PHP function file_get_contents() and not getfilecontents() as I saw elsewhere in this forum.

Does anyone know what I'm doing wrong here? Thanks in advance for your help.

DirectAdmin Support
10-17-2006, 10:29 AM
Hello,

Use the php communication class.
Api info here:
http://www.directadmin.com/api.html

Php Class Info here:
http://www.directadmin.com/forum/showthread.php?threadid=258

John