This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation. |
API calls
From Group-Office Groupware and CRM Documentation
Logging in
You can login to Group-Office using http calls. Here's a PHP CURL example:
<?php $tmpdir = '/tmp'; $baseUrl = 'http://localhost/groupoffice/index.php'; $username = 'admin'; $password = 'admin'; $ch = curl_init(); $cookieFile = $tmpdir . '/cookie.txt'; curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile); //for self-signed certificates curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_ENCODING, "UTF-8"); $postfields = array( 'username' => $username, 'password' => $password ); curl_setopt($ch, CURLOPT_URL,$baseUrl . '?r=auth/login'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $error = curl_error($ch); if(!empty($error)) die("curl error: ".$error); $response = json_decode($response, true); var_dump($response);
Running this script should return something like:
array(4) { ["success"]=> bool(true) ["user_id"]=> string(1) "1" ["security_token"]=> string(20) "nbhr9pmksfvg4czwjldq" ["sid"]=> string(26) "eiijnl8iupkk345qpnhaukvml6" }
The security token must be send as parameter to each request. Learn more about controller actions on the Controllers page.