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
(→Logging in) |
(→Logging in) |
||
Line 1: | Line 1: | ||
==Logging in== | ==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. | |
<pre> | <pre> | ||
+ | |||
<?php | <?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"; | |
− | ); | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | < | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
</pre> | </pre> | ||
− | |||
− |
Revision as of 14:35, 27 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"; }