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_mail_format' => 'Both',
62 'first_name' => 'abc3',
64 'last_name' => 'xyz3',
68 'deceased_date' => '',
69 'household_name' => '',
70 'organization_name' => '',
72 'contact_is_deleted' => 0,
73 'current_employer' => '',
75 'street_address' => '',
76 'supplemental_address_1' => '',
77 'supplemental_address_2' => '',
79 'postal_code_suffix' => '',
83 'state_province_id' => '',
84 'state_province_name' => '',
85 'state_province' => '',
89 'phone_type_id' => '',
92 'email' => 'man3@yahoo.com',
97 'worldregion_id' => '',
100 'api.website.getValue' => 'http://civicrm.org',
101 'api.Contribution.getCount' => 2,
102 'api.CustomValue.get' => array(
108 'api.Note.get' => array(
114 'api.Membership.getCount' => 0,
119 return $expectedResult;
124 * This example has been generated from the API test suite. The test that created it is called
126 * testGetIndividualWithChainedArraysFormats and can be found in
127 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
129 * You can see the outcome of the API tests at
130 * http://tests.dev.civicrm.org/trunk/results-api_v3
132 * To Learn about the API read
133 * http://book.civicrm.org/developer/current/techniques/api/
135 * and review the wiki at
136 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
138 * Read more about testing here
139 * http://wiki.civicrm.org/confluence/display/CRM/Testing
141 * API Standards documentation:
142 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards