4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using contact create API.
11 * /*this demonstrates setting a custom field through the API
16 function contact_create_example() {
18 'first_name' => 'abc1',
19 'contact_type' => 'Individual',
20 'last_name' => 'xyz1',
21 'custom_1' => 'custom string',
25 $result = civicrm_api3('contact', 'create', $params);
27 catch (CiviCRM_API3_Exception
$e) {
29 $errorMessage = $e->getMessage();
30 $errorCode = $e->getErrorCode();
31 $errorData = $e->getExtraParams();
33 'error' => $errorMessage,
34 'error_code' => $errorCode,
35 'error_data' => $errorData,
43 * Function returns array of result expected from previous function.
48 function contact_create_expectedresult() {
50 $expectedResult = array(
58 'contact_type' => 'Individual',
59 'contact_sub_type' => '',
66 'legal_identifier' => '',
67 'external_identifier' => '',
68 'sort_name' => 'xyz1, abc1',
69 'display_name' => 'abc1 xyz1',
73 'preferred_communication_method' => '',
74 'preferred_language' => 'en_US',
75 'preferred_mail_format' => 'Both',
76 'hash' => '67eac7789eaee00',
78 'first_name' => 'abc1',
80 'last_name' => 'xyz1',
84 'communication_style_id' => '',
85 'email_greeting_id' => '1',
86 'email_greeting_custom' => '',
87 'email_greeting_display' => '',
88 'postal_greeting_id' => '1',
89 'postal_greeting_custom' => '',
90 'postal_greeting_display' => '',
91 'addressee_id' => '1',
92 'addressee_custom' => '',
93 'addressee_display' => '',
98 'deceased_date' => '',
99 'household_name' => '',
100 'primary_contact_id' => '',
101 'organization_name' => '',
103 'user_unique_id' => '',
104 'created_date' => '2013-07-28 08:49:19',
105 'modified_date' => '2012-11-14 16:02:35',
110 return $expectedResult;
114 * This example has been generated from the API test suite.
115 * The test that created it is called
116 * testCreateWithCustom
117 * and can be found in
118 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
120 * You can see the outcome of the API tests at
121 * https://test.civicrm.org/job/CiviCRM-master-git/
123 * To Learn about the API read
124 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
126 * Browse the api on your own site with the api explorer
127 * http://MYSITE.ORG/path/to/civicrm/api/explorer
129 * Read more about testing here
130 * http://wiki.civicrm.org/confluence/display/CRM/Testing
132 * API Standards documentation:
133 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards