3 * Test Generated example of using contact create API
4 * /*this demonstrates setting a custom field through the API *
6 function contact_create_example(){
8 'first_name' => 'abc1',
9 'contact_type' => 'Individual',
10 'last_name' => 'xyz1',
11 'custom_1' => 'custom string',
15 $result = civicrm_api3('contact', 'create', $params);
17 catch (CiviCRM_API3_Exception
$e) {
19 $errorMessage = $e->getMessage();
20 $errorCode = $e->getErrorCode();
21 $errorData = $e->getExtraParams();
22 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
29 * Function returns array of result expected from previous function
31 function contact_create_expectedresult(){
33 $expectedResult = array(
41 'contact_type' => 'Individual',
42 'contact_sub_type' => '',
49 'legal_identifier' => '',
50 'external_identifier' => '',
51 'sort_name' => 'xyz1, abc1',
52 'display_name' => 'abc1 xyz1',
56 'preferred_communication_method' => '',
57 'preferred_language' => 'en_US',
58 'preferred_mail_format' => 'Both',
59 'hash' => '67eac7789eaee00',
61 'first_name' => 'abc1',
63 'last_name' => 'xyz1',
66 'email_greeting_id' => '1',
67 'email_greeting_custom' => '',
68 'email_greeting_display' => '',
69 'postal_greeting_id' => '1',
70 'postal_greeting_custom' => '',
71 'postal_greeting_display' => '',
72 'addressee_id' => '1',
73 'addressee_custom' => '',
74 'addressee_display' => '',
79 'deceased_date' => '',
80 'household_name' => '',
81 'primary_contact_id' => '',
82 'organization_name' => '',
84 'user_unique_id' => '',
85 'created_date' => '2013-07-28 08:49:19',
86 'modified_date' => '2012-11-14 16:02:35',
91 return $expectedResult;
96 * This example has been generated from the API test suite. The test that created it is called
98 * testCreateWithCustom and can be found in
99 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
101 * You can see the outcome of the API tests at
102 * http://tests.dev.civicrm.org/trunk/results-api_v3
104 * To Learn about the API read
105 * http://book.civicrm.org/developer/current/techniques/api/
107 * and review the wiki at
108 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
110 * Read more about testing here
111 * http://wiki.civicrm.org/confluence/display/CRM/Testing
113 * API Standards documentation:
114 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards