3 * Test Generated example of using contact get API
4 * /*this demonstrates the usage of chained api functions. A variety of techniques are used *
6 function contact_get_example(){
9 'api.website.getValue' => array(
12 'api.Contribution.getCount' => array(),
13 'api.CustomValue.get' => 1,
17 $result = civicrm_api3('contact', 'get', $params);
19 catch (CiviCRM_API3_Exception
$e) {
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
31 * Function returns array of result expected from previous function
33 function contact_get_expectedresult(){
35 $expectedResult = array(
43 'contact_type' => 'Individual',
44 'contact_sub_type' => '',
45 'sort_name' => 'xyz3, abc3',
46 'display_name' => 'abc3 xyz3',
53 'legal_identifier' => '',
54 'external_identifier' => '',
58 'preferred_mail_format' => 'Both',
59 'first_name' => 'abc3',
61 'last_name' => 'xyz3',
65 'deceased_date' => '',
66 'household_name' => '',
67 'organization_name' => '',
69 'contact_is_deleted' => 0,
70 'current_employer' => '',
72 'street_address' => '',
73 'supplemental_address_1' => '',
74 'supplemental_address_2' => '',
76 'postal_code_suffix' => '',
80 'state_province_id' => '',
83 'phone_type_id' => '',
86 'email' => 'man3@yahoo.com',
91 'worldregion_id' => '',
93 'state_province_name' => '',
94 'state_province' => '',
97 'api.website.getValue' => 'http://civicrm.org',
98 'api.Contribution.getCount' => 2,
99 'api.CustomValue.get' => array(
106 'latest' => 'value 4',
108 'entity_table' => 'Contact',
111 'entity_table' => 'Contact',
115 'latest' => 'value 3',
118 'entity_table' => 'Contact',
143 'latest' => 'vegemite',
159 return $expectedResult;
164 * This example has been generated from the API test suite. The test that created it is called
166 * testGetIndividualWithChainedArraysAndMultipleCustom and can be found in
167 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
169 * You can see the outcome of the API tests at
170 * http://tests.dev.civicrm.org/trunk/results-api_v3
172 * To Learn about the API read
173 * http://book.civicrm.org/developer/current/techniques/api/
175 * and review the wiki at
176 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
178 * Read more about testing here
179 * http://wiki.civicrm.org/confluence/display/CRM/Testing
181 * API Standards documentation:
182 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards