AnsweredAssumed Answered

login problem through api

Question asked by dhaivatnaik on Oct 13, 2010
Latest reply on Oct 22, 2010 by ddanninger
Hello Everybody,

I am new to alfresco, I am trying to integrate alfresco to my php application through webservice. I started with RestFull Api login method.

I successfully got the ticket when i call the /alfresco/service/api/login with GET.
I am wondering how to call the login through POST and get ticket (authenticated).

this is what i did

$url = 'http://myserver/alfresco/service/api/login';
$aData = array(   'username'=>'admin',
      'password'=> 'admin'
         );
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_HEADER, true);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS,array($aData));

      $result = curl_exec($ch);
      $response = curl_getinfo($ch);   
      curl_close($ch);

but it gives me following error

HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Connection: close

i also tried with


$aData = array(   'username'=>'admin',
      'password'=> 'admin'
         );
   $jsonenc = json_encode($aData);
   curl_setopt($ch, CURLOPT_HEADER,array('Content-Type: application/json'));
   curl_setopt($ch, CURLOPT_POSTFIELDS,array($jsonenc));

it didn't worked too. Can anybody please tell me what is wrong? what can be done?

Thanks in advance,
Dhaivat

Outcomes