3 * Test Generated example demonstrating the Contact.create API.
5 * This demonstrates setting a custom field through the API.
10 function contact_create_example() {
12 'first_name' => 'abc1',
13 'contact_type' => 'Individual',
14 'last_name' => 'xyz1',
15 'custom_1' => 'custom string',
19 $result = civicrm_api3('Contact', 'create', $params);
21 catch (CiviCRM_API3_Exception
$e) {
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
28 'error_message' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
38 * Function returns array of result expected from previous function.
43 function contact_create_expectedresult() {
53 'contact_type' => 'Individual',
54 'contact_sub_type' => '',
61 'legal_identifier' => '',
62 'external_identifier' => '',
63 'sort_name' => 'xyz1, abc1',
64 'display_name' => 'abc1 xyz1',
68 'preferred_communication_method' => '',
69 'preferred_language' => 'en_US',
70 'preferred_mail_format' => 'Both',
71 'hash' => '67eac7789eaee00',
73 'first_name' => 'abc1',
75 'last_name' => 'xyz1',
79 'communication_style_id' => '',
80 'email_greeting_id' => '1',
81 'email_greeting_custom' => '',
82 'email_greeting_display' => '',
83 'postal_greeting_id' => '1',
84 'postal_greeting_custom' => '',
85 'postal_greeting_display' => '',
86 'addressee_id' => '1',
87 'addressee_custom' => '',
88 'addressee_display' => '',
93 'deceased_date' => '',
94 'household_name' => '',
95 'primary_contact_id' => '',
96 'organization_name' => '',
98 'user_unique_id' => '',
99 'created_date' => '2013-07-28 08:49:19',
100 'modified_date' => '2012-11-14 16:02:35',
105 return $expectedResult;
109 * This example has been generated from the API test suite.
110 * The test that created it is called "testCreateWithCustom"
111 * and can be found at:
112 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
114 * You can see the outcome of the API tests at
115 * https://test.civicrm.org/job/CiviCRM-master-git/
117 * To Learn about the API read
118 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
120 * Browse the api on your own site with the api explorer
121 * http://MYSITE.ORG/path/to/civicrm/api
123 * Read more about testing here
124 * http://wiki.civicrm.org/confluence/display/CRM/Testing
126 * API Standards documentation:
127 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards