3 * Test Generated example demonstrating the Contact.create API.
5 * Demonstrates creating two websites as an array.
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' => 67890,
27 'contribution_status_id' => 1,
29 'api.website.create' => array(
31 'url' => 'http://civicrm.org',
34 'url' => 'http://chained.org',
35 'website_type_id' => 2,
41 $result = civicrm_api3('Contact', 'create', $params);
43 catch (CiviCRM_API3_Exception
$e) {
45 $errorMessage = $e->getMessage();
46 $errorCode = $e->getErrorCode();
47 $errorData = $e->getExtraParams();
49 'error' => $errorMessage,
50 'error_code' => $errorCode,
51 'error_data' => $errorData,
59 * Function returns array of result expected from previous function.
64 function contact_create_expectedresult() {
66 $expectedResult = array(
74 'contact_type' => 'Individual',
75 'contact_sub_type' => '',
82 'legal_identifier' => '',
83 'external_identifier' => '',
84 'sort_name' => 'xyz3, abc3',
85 'display_name' => 'abc3 xyz3',
89 'preferred_communication_method' => '',
90 'preferred_language' => 'en_US',
91 'preferred_mail_format' => 'Both',
92 'hash' => '67eac7789eaee00',
94 'first_name' => 'abc3',
96 'last_name' => 'xyz3',
100 'communication_style_id' => '',
101 'email_greeting_id' => '1',
102 'email_greeting_custom' => '',
103 'email_greeting_display' => '',
104 'postal_greeting_id' => '1',
105 'postal_greeting_custom' => '',
106 'postal_greeting_display' => '',
107 'addressee_id' => '1',
108 'addressee_custom' => '',
109 'addressee_display' => '',
114 'deceased_date' => '',
115 'household_name' => '',
116 'primary_contact_id' => '',
117 'organization_name' => '',
119 'user_unique_id' => '',
120 'created_date' => '2013-07-28 08:49:19',
121 'modified_date' => '2012-11-14 16:02:35',
122 'api.contribution.create' => array(
131 'financial_type_id' => '1',
132 'contribution_page_id' => '',
133 'payment_instrument_id' => '1',
134 'receive_date' => '20100101000000',
135 'non_deductible_amount' => '10',
136 'total_amount' => '100',
137 'fee_amount' => '50',
138 'net_amount' => '90',
139 'trxn_id' => '12345',
140 'invoice_id' => '67890',
143 'cancel_reason' => '',
144 'receipt_date' => '',
145 'thankyou_date' => '',
147 'amount_level' => '',
148 'contribution_recur_id' => '',
150 'is_pay_later' => '',
151 'contribution_status_id' => '1',
153 'check_number' => '',
155 'creditnote_id' => '',
157 'contribution_type_id' => '1',
161 'api.website.create' => array(
171 'url' => 'http://civicrm.org',
172 'website_type_id' => '',
185 'url' => 'http://chained.org',
186 'website_type_id' => '2',
195 return $expectedResult;
199 * This example has been generated from the API test suite.
200 * The test that created it is called "testCreateIndividualWithContributionChainedArrays"
201 * and can be found at:
202 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
204 * You can see the outcome of the API tests at
205 * https://test.civicrm.org/job/CiviCRM-master-git/
207 * To Learn about the API read
208 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
210 * Browse the api on your own site with the api explorer
211 * http://MYSITE.ORG/path/to/civicrm/api
213 * Read more about testing here
214 * http://wiki.civicrm.org/confluence/display/CRM/Testing
216 * API Standards documentation:
217 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards