3 * Test Generated example demonstrating the Contact.create API.
5 * This demonstrates the syntax to create 2 chained entities.
10 function contact_create_example() {
12 'first_name' => 'abc3',
13 'last_name' => 'xyz3',
14 'contact_type' => 'Individual',
15 'email' => 'man3@yahoo.com',
16 'api.contribution.create' => array(
17 'receive_date' => '2010-01-01',
18 'total_amount' => '100',
19 'financial_type_id' => 1,
20 'payment_instrument_id' => 1,
21 'non_deductible_amount' => '10',
25 'invoice_id' => 67990,
27 'contribution_status_id' => 1,
29 'api.website.create' => array(
30 'url' => 'http://civicrm.org',
32 'api.website.create.2' => array(
33 'url' => 'http://chained.org',
38 $result = civicrm_api3('Contact', 'create', $params);
40 catch (CiviCRM_API3_Exception
$e) {
42 $errorMessage = $e->getMessage();
43 $errorCode = $e->getErrorCode();
44 $errorData = $e->getExtraParams();
47 'error_message' => $errorMessage,
48 'error_code' => $errorCode,
49 'error_data' => $errorData,
57 * Function returns array of result expected from previous function.
62 function contact_create_expectedresult() {
64 $expectedResult = array(
72 'contact_type' => 'Individual',
73 'contact_sub_type' => '',
80 'legal_identifier' => '',
81 'external_identifier' => '',
82 'sort_name' => 'xyz3, abc3',
83 'display_name' => 'abc3 xyz3',
87 'preferred_communication_method' => '',
88 'preferred_language' => 'en_US',
89 'preferred_mail_format' => 'Both',
90 'hash' => '67eac7789eaee00',
92 'first_name' => 'abc3',
94 'last_name' => 'xyz3',
98 'communication_style_id' => '',
99 'email_greeting_id' => '1',
100 'email_greeting_custom' => '',
101 'email_greeting_display' => '',
102 'postal_greeting_id' => '1',
103 'postal_greeting_custom' => '',
104 'postal_greeting_display' => '',
105 'addressee_id' => '1',
106 'addressee_custom' => '',
107 'addressee_display' => '',
112 'deceased_date' => '',
113 'household_name' => '',
114 'primary_contact_id' => '',
115 'organization_name' => '',
117 'user_unique_id' => '',
118 'created_date' => '2013-07-28 08:49:19',
119 'modified_date' => '2012-11-14 16:02:35',
120 'api.contribution.create' => array(
129 'financial_type_id' => '1',
130 'contribution_page_id' => '',
131 'payment_instrument_id' => '1',
132 'receive_date' => '20100101000000',
133 'non_deductible_amount' => '10',
134 'total_amount' => '100',
135 'fee_amount' => '50',
136 'net_amount' => '90',
137 'trxn_id' => '15345',
138 'invoice_id' => '67990',
141 'cancel_reason' => '',
142 'receipt_date' => '',
143 'thankyou_date' => '',
145 'amount_level' => '',
146 'contribution_recur_id' => '',
148 'is_pay_later' => '',
149 'contribution_status_id' => '1',
151 'check_number' => '',
153 'creditnote_id' => '',
155 'revenue_recognition_date' => '',
156 'contribution_type_id' => '1',
160 'api.website.create' => array(
169 'url' => 'http://civicrm.org',
170 'website_type_id' => '',
174 'api.website.create.2' => array(
183 'url' => 'http://chained.org',
184 'website_type_id' => '',
192 return $expectedResult;
196 * This example has been generated from the API test suite.
197 * The test that created it is called "testCreateIndividualWithContributionDottedSyntax"
198 * and can be found at:
199 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
201 * You can see the outcome of the API tests at
202 * https://test.civicrm.org/job/CiviCRM-master-git/
204 * To Learn about the API read
205 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
207 * Browse the api on your own site with the api explorer
208 * http://MYSITE.ORG/path/to/civicrm/api
210 * Read more about testing here
211 * http://wiki.civicrm.org/confluence/display/CRM/Testing
213 * API Standards documentation:
214 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards