3 * Test Generated example demonstrating the Contact.get API.
5 * Get contact id of the current logged in user
10 function contact_get_example() {
12 'id' => 'user_contact_id',
16 $result = civicrm_api3('Contact', 'get', $params);
18 catch (CiviCRM_API3_Exception
$e) {
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
25 'error_message' => $errorMessage,
26 'error_code' => $errorCode,
27 'error_data' => $errorData,
35 * Function returns array of result expected from previous function.
40 function contact_get_expectedresult() {
42 $expectedResult = array(
50 'contact_type' => 'Individual',
51 'contact_sub_type' => '',
52 'sort_name' => 'User 412074113, Logged In',
53 'display_name' => 'Mr. Logged In User 412074113 II',
60 'legal_identifier' => '',
61 'external_identifier' => '',
65 'preferred_communication_method' => '',
66 'preferred_language' => 'en_US',
67 'preferred_mail_format' => 'Both',
68 'first_name' => 'Logged In',
69 'middle_name' => 'J.',
70 'last_name' => 'User 412074113',
74 'communication_style_id' => '',
79 'deceased_date' => '',
80 'household_name' => '',
81 'organization_name' => '',
83 'contact_is_deleted' => 0,
84 'current_employer' => '',
86 'street_address' => '',
87 'supplemental_address_1' => '',
88 'supplemental_address_2' => '',
90 'postal_code_suffix' => '',
94 'state_province_id' => '',
97 'phone_type_id' => '',
100 'email' => 'anthony_anderson@civicrm.org',
105 'worldregion_id' => '',
106 'world_region' => '',
107 'languages' => 'English (United States)',
108 'individual_prefix' => 'Mr.',
109 'individual_suffix' => 'II',
110 'communication_style' => '',
112 'state_province_name' => '',
113 'state_province' => '',
120 return $expectedResult;
124 * This example has been generated from the API test suite.
125 * The test that created it is called "testLoggedInUserAPISupportToken"
126 * and can be found at:
127 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
129 * You can see the outcome of the API tests at
130 * https://test.civicrm.org/job/CiviCRM-master-git/
132 * To Learn about the API read
133 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
135 * Browse the api on your own site with the api explorer
136 * http://MYSITE.ORG/path/to/civicrm/api
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