-
- This class allows to consume the API, either from within a module that knows civicrm already:
-
- require_once('api/class/api.php');
- $api = new civicrm_api3();
-
- or from any code on the same server as civicrm
-
- require_once('/your/civi/folder/api/class.api.php');
- // the path to civicrm.settings.php
- $api = new civicrm_api3 (array('conf_path'=> '/your/path/to/your/civicrm/or/joomla/site));
-
- or to query a remote server via the rest api
-
- $api = new civicrm_api3 (array ('server' => 'http://example.org','api_key'=>'theusersecretkey','key'=>'thesitesecretkey'));
-
- no matter how initialised and if civicrm is local or remote, you use the class the same way
-
- $api->{entity}->{action}($params);
-
- so to get the individual contacts
-
- if ($api->Contact->Get(array(
- 'contact_type'=>'Individual','return'=>'sort_name,current_employer')) {
- // each key of the result array is an attribute of the api
- echo "\n contacts found " . $api->count;
- foreach ($api->values as $c) {
- echo "\n".$c->sort_name. " working for ". $c->current_employer;
- }
- // in theory, doesn't append
- } else {
- echo $api->errorMsg();
- }
-
- or to create an event
-
- if ($api->Event->Create(array(
- 'title'=>'Test','event_type_id' => 1,'is_public' => 1,'start_date' => 19430429))) {
- echo "created event id:". $api->id;
- } else {
- echo $api->errorMsg();
- }
-
- To make it easier, the Actions can either take for input an associative array $params, or simply an id
-
- $api->Activity->Get (42);
-
- being the same as:
-
- $api->Activity->Get (array('id'=>42));
-
- you can too get the result like what civicrm_api does, but as an object instead of an array (eg $entity->attribute instead of $entity['attribute']
-
- $result = $api->result;
- // is the json encoded result
- echo $api;
-
+ *
+ * This class allows to consume the API, either from within a module that knows civicrm already:
+ *
+ * @code
+ * require_once('api/class/api.php');
+ * $api = new civicrm_api3();
+ * @endcode
+ *
+ * or from any code on the same server as civicrm
+ *
+ * @code
+ * require_once('/your/civi/folder/api/class.api.php');
+ * // the path to civicrm.settings.php
+ * $api = new civicrm_api3 (array('conf_path'=> '/your/path/to/your/civicrm/or/joomla/site));
+ * @endcode
+ *
+ * or to query a remote server via the rest api
+ *
+ * @code
+ * $api = new civicrm_api3 (array ('server' => 'http://example.org','api_key'=>'theusersecretkey','key'=>'thesitesecretkey'));
+ * @endcode
+ *
+ * No matter how initialised and if civicrm is local or remote, you use the class the same way.
+ *
+ * @code
+ * $api->{entity}->{action}($params);
+ * @endcode
+ *
+ * So, to get the individual contacts:
+ *
+ * @code
+ * if ($api->Contact->Get(array('contact_type'=>'Individual','return'=>'sort_name,current_employer')) {
+ * // each key of the result array is an attribute of the api
+ * echo "\n contacts found " . $api->count;
+ * foreach ($api->values as $c) {
+ * echo "\n".$c->sort_name. " working for ". $c->current_employer;
+ * }
+ * // in theory, doesn't append
+ * } else {
+ * echo $api->errorMsg();
+ * }
+ * @endcode
+ *
+ * Or, to create an event:
+ *
+ * @code
+ * if ($api->Event->Create(array('title'=>'Test','event_type_id' => 1,'is_public' => 1,'start_date' => 19430429))) {
+ * echo "created event id:". $api->id;
+ * } else {
+ * echo $api->errorMsg();
+ * }
+ * @endcode
+ *
+ * To make it easier, the Actions can either take for input an
+ * associative array $params, or simply an id. The following two lines
+ * are equivalent.
+ *
+ * @code
+ * $api->Activity->Get (42);
+ * $api->Activity->Get (array('id'=>42));
+ * @endcode
+ *
+ *
+ * You can also get the result like civicrm_api does, but as an object
+ * instead of an array (eg $entity->attribute instead of
+ * $entity['attribute']).
+ *
+ * @code
+ * $result = $api->result;
+ * // is the json encoded result
+ * echo $api;
+ * @endcode