Cant login to DA with the PHP API

sky

Verified User
Joined
Nov 12, 2004
Messages
318
Hello

I have been using DA's API for a while now and on one server it cant seem to connect anymore.

This is what i send :
Code:
GET /CMD_API_DOMAIN_POINTER?domain=domain.fr&action=add&from=test.domain.fr&alias=yes HTTP/1.0 User-Agent: HTTPSocket/2.6 Host: 91.121.183.75:2222 Accept: */* Connection: Close Authorization: Basic FDHSDJFKGSHFDLKGJFDGHLSKJGHFDSLGK=
(i tampered the login & password)

This is what i get back :
Code:
HTTP/1.1 200 OK Server: DirectAdmin Daemon v1.36.0 Registered to Name Surname Set-Cookie: session=; path=/; HttpOnly Connection: close Cache-Control: no-cache Pragma: no-cache X-DirectAdmin: unauthorized Content-Type: text/html
+ the login form.

The PHP snippet :
Code:
    $sock = new HTTPSocket;
    $sock->connect($CFG['server_ip'], 2222);
    $sock->set_login($CFG['server_login'], $CFG['server_pass']);

    // sub domain
    $sock->query('/CMD_API_DOMAIN_POINTER',
             array(
                    'domain' => 'domain.fr',
                    'action' => 'add',
                    'from' => $domaine,
                    'alias' => 'yes'
                   )
             );

I use the HTTPSocket class and custom PHP scripting for creating domain aliases and ftp accounts for a project.

I also tried using the API with the da_admin account, but no luck.

I tried desqactivating the firewall in case ... but no luck.


Did something change in DA API system ?

Thx for your help,
Sky


Edit : tested the login and password direct with the DA classic web interface : all's fine.
This problem is only when login in with the API.
 
Last edited:
This started after a server transfert.

Is there a new API feature like the referer check ?
 
Hello,

If you've restore your "admin" account, then the admin password become that of the old box, so update the password in the script to the old box's admin pass.

For debugging API bits, I recommend using this to compare what a browser passes, vs what your script is passing:
http://help.directadmin.com/item.php?id=293

And yes actually, there was a new feature added a while back.. but I beleive the API calls are exempt:
http://www.directadmin.com/features.php?id=1050
http://www.directadmin.com/features.php?id=1054

John
 
Thx John, ill give that a try.

I did change the password, but it whas not the admin one but the user password.

Sky
 
Hello

So the reason is : "didn't find the encrytped text"
The login+password is not correct ?
 
Hello,

The error
Code:
didn't find the encrytped text
means that the header with the base64 data wasn't passed to DA at all. The header in question is called "Authorization:", it needs to be passed. The value should start with "Basic" and continue on with the base64 version of user:pass.

John
 
Hello

Sorry for this, it whas a error in the class wrapper i made.

Excuses,
Sky
 
Back
Top