3 * Test Generated example of using contact get API
4 * /*this demonstrates the usage of chained api functions. A variety of return formats are used. Note that no notes
5 *custom fields or memberships exist *
7 function contact_get_example(){
10 'api.website.getValue' => array(
13 'api.Contribution.getCount' => array(),
14 'api.CustomValue.get' => 1,
16 'api.Membership.getCount' => array(),
20 $result = civicrm_api3('contact', 'get', $params);
22 catch (CiviCRM_API3_Exception
$e) {
24 $errorMessage = $e->getMessage();
25 $errorCode = $e->getErrorCode();
26 $errorData = $e->getExtraParams();
27 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
34 * Function returns array of result expected from previous function
36 function contact_get_expectedresult(){
38 $expectedResult = array(
46 'contact_type' => 'Individual',
47 'contact_sub_type' => '',
48 'sort_name' => 'xyz3, abc3',
49 'display_name' => 'abc3 xyz3',
56 'legal_identifier' => '',
57 'external_identifier' => '',
61 'preferred_communication_method' => '',
62 'preferred_language' => 'en_US',
63 'preferred_mail_format' => 'Both',
64 'first_name' => 'abc3',
66 'last_name' => 'xyz3',
73 'deceased_date' => '',
74 'household_name' => '',
75 'organization_name' => '',
77 'contact_is_deleted' => 0,
78 'current_employer' => '',
80 'street_address' => '1 my road',
81 'supplemental_address_1' => '',
82 'supplemental_address_2' => '',
84 'postal_code_suffix' => '',
88 'state_province_id' => '',
91 'phone_type_id' => '',
94 'email' => 'man3@yahoo.com',
99 'worldregion_id' => '',
100 'world_region' => '',
101 'individual_prefix' => '',
102 'individual_suffix' => '',
104 'state_province_name' => '',
105 'state_province' => '',
108 'api.website.getValue' => 'http://civicrm.org',
109 'api.Contribution.getCount' => 2,
110 'api.CustomValue.get' => array(
116 'api.Note.get' => array(
122 'api.Membership.getCount' => 0,
127 return $expectedResult;
132 * This example has been generated from the API test suite. The test that created it is called
134 * testGetIndividualWithChainedArraysFormats and can be found in
135 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
137 * You can see the outcome of the API tests at
138 * https://test.civicrm.org/job/CiviCRM-master-git/
140 * To Learn about the API read
141 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
143 * Browse the api on your own site with the api explorer
144 * http://MYSITE.ORG/path/to/civicrm/api/explorer
146 * Read more about testing here
147 * http://wiki.civicrm.org/confluence/display/CRM/Testing
149 * API Standards documentation:
150 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards