3 * Test Generated example demonstrating the Contact.get API.
5 * This demonstrates the usage of chained api functions.
6 * In this case no notes or custom fields have been created.
11 function contact_get_example() {
14 'api.website.getValue' => [
17 'api.Contribution.getCount' => [],
18 'api.CustomValue.get' => 1,
20 'api.Membership.getCount' => [],
24 $result = civicrm_api3('Contact', 'get', $params);
26 catch (CiviCRM_API3_Exception
$e) {
28 $errorMessage = $e->getMessage();
29 $errorCode = $e->getErrorCode();
30 $errorData = $e->getExtraParams();
33 'error_message' => $errorMessage,
34 'error_code' => $errorCode,
35 'error_data' => $errorData,
43 * Function returns array of result expected from previous function.
48 function contact_get_expectedresult() {
58 'contact_type' => 'Individual',
59 'contact_sub_type' => '',
60 'sort_name' => 'xyz3, abc3',
61 'display_name' => 'abc3 xyz3',
68 'legal_identifier' => '',
69 'external_identifier' => '',
73 'preferred_communication_method' => '',
74 'preferred_language' => 'en_US',
75 'preferred_mail_format' => 'Both',
76 'first_name' => 'abc3',
78 'last_name' => 'xyz3',
82 'communication_style_id' => '',
87 'deceased_date' => '',
88 'household_name' => '',
89 'organization_name' => '',
91 'contact_is_deleted' => 0,
92 'current_employer' => '',
94 'street_address' => '',
95 'supplemental_address_1' => '',
96 'supplemental_address_2' => '',
97 'supplemental_address_3' => '',
99 'postal_code_suffix' => '',
103 'state_province_id' => '',
106 'phone_type_id' => '',
109 'email' => 'man3@yahoo.com',
114 'worldregion_id' => '',
115 'world_region' => '',
116 'languages' => 'English (United States)',
117 'individual_prefix' => '',
118 'individual_suffix' => '',
119 'communication_style' => '',
121 'state_province_name' => '',
122 'state_province' => '',
125 'api.website.getValue' => 'http://civicrm.org',
126 'api.Contribution.getCount' => 2,
127 'api.CustomValue.get' => [
139 'api.Membership.getCount' => 0,
144 return $expectedResult;
148 * This example has been generated from the API test suite.
149 * The test that created it is called "testGetIndividualWithChainedArraysFormats"
150 * and can be found at:
151 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
153 * You can see the outcome of the API tests at
154 * https://test.civicrm.org/job/CiviCRM-master-git/
156 * To Learn about the API read
157 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
159 * Browse the api on your own site with the api explorer
160 * http://MYSITE.ORG/path/to/civicrm/api
162 * Read more about testing here
163 * http://wiki.civicrm.org/confluence/display/CRM/Testing
165 * API Standards documentation:
166 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards