This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation.

Difference between revisions of "API calls"

From Group-Office Groupware and CRM Documentation
Jump to: navigation, search
(Logging in)
 
Line 33: Line 33:
 
   echo $record->name."<br>\n";
 
   echo $record->name."<br>\n";
 
}
 
}
 +
</pre>
 +
 +
==Browser autologin script==
 +
 +
If you want to create some kind os single sign on solution in the browser, this script may get you started:
 +
<pre>
 +
<?php
 +
require('/path/to/GO.php');
 +
 +
$user='Get the username in a very secure way!';
 +
$pass='Get the password in a very secure way!';
 +
 +
GO::session()->login($user, $pass);
 +
 +
header('Location: /url/to/groupoffice');
 
</pre>
 
</pre>

Latest revision as of 16:42, 28 August 2013

Logging in

Here's some sample code on how to login to Group-Office with the CURL based HTTP client and get notes from the demo.


<?php

//Adjust this path to suit your needs
require('/usr/share/groupoffice/GO.php');

//not required but can be used to get CLI input params
$params = GO_Base_Util_Cli::parseArgs();

$host = 'http://demo.group-office.eu/';

//Login
$httpClient = new GO_Base_Util_HttpClient();
$success = $httpClient->groupofficeLogin($host, 'demo','demo');

if(!$success)
        throw new Exception("Could not login to Group-Office");

//Get notes
$response = $httpClient->request($host,array(
                'r'=>'notes/note/store',
      'start'=>0,
      'limit'=>10

));

$result = json_decode($response);
//print names
foreach($result->results as $record){
   echo $record->name."<br>\n";
}

Browser autologin script

If you want to create some kind os single sign on solution in the browser, this script may get you started:

<?php
require('/path/to/GO.php');

$user='Get the username in a very secure way!';
$pass='Get the password in a very secure way!';

GO::session()->login($user, $pass);

header('Location: /url/to/groupoffice');