3 * Test Generated example of using contact create API
4 * demonstrates creating two websites as an array *
6 function contact_create_example(){
8 'first_name' => 'abc3',
10 'contact_type' => 'Individual',
11 'email' => 'man3@yahoo.com',
12 'api.contribution.create' => array(
13 'receive_date' => '2010-01-01',
14 'total_amount' => '100',
15 'financial_type_id' => 1,
16 'payment_instrument_id' => 1,
17 'non_deductible_amount' => '10',
21 'invoice_id' => 67890,
23 'contribution_status_id' => 1,
25 'api.website.create' => array(
27 'url' => 'http://civicrm.org',
30 'url' => 'http://chained.org',
31 'website_type_id' => 2,
37 $result = civicrm_api3('contact', 'create', $params);
39 catch (CiviCRM_API3_Exception
$e) {
41 $errorMessage = $e->getMessage();
42 $errorCode = $e->getErrorCode();
43 $errorData = $e->getExtraParams();
44 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
51 * Function returns array of result expected from previous function
53 function contact_create_expectedresult(){
55 $expectedResult = array(
63 'contact_type' => 'Individual',
64 'contact_sub_type' => '',
71 'legal_identifier' => '',
72 'external_identifier' => '',
73 'sort_name' => 'xyz3, abc3',
74 'display_name' => 'abc3 xyz3',
78 'preferred_communication_method' => '',
79 'preferred_language' => 'en_US',
80 'preferred_mail_format' => 'Both',
81 'hash' => '67eac7789eaee00',
83 'first_name' => 'abc3',
85 'last_name' => 'xyz3',
88 'email_greeting_id' => '1',
89 'email_greeting_custom' => '',
90 'email_greeting_display' => '',
91 'postal_greeting_id' => '1',
92 'postal_greeting_custom' => '',
93 'postal_greeting_display' => '',
94 'addressee_id' => '1',
95 'addressee_custom' => '',
96 'addressee_display' => '',
101 'deceased_date' => '',
102 'household_name' => '',
103 'primary_contact_id' => '',
104 'organization_name' => '',
106 'user_unique_id' => '',
107 'created_date' => '2013-07-28 08:49:19',
108 'modified_date' => '2012-11-14 16:02:35',
109 'api.contribution.create' => array(
118 'financial_type_id' => '1',
119 'contribution_page_id' => '',
120 'payment_instrument_id' => '1',
121 'receive_date' => '20100101000000',
122 'non_deductible_amount' => '10',
123 'total_amount' => '100',
124 'fee_amount' => '50',
125 'net_amount' => '90',
126 'trxn_id' => '12345',
127 'invoice_id' => '67890',
130 'cancel_reason' => '',
131 'receipt_date' => '',
132 'thankyou_date' => '',
134 'amount_level' => '',
135 'contribution_recur_id' => '',
136 'honor_contact_id' => '',
138 'is_pay_later' => '',
139 'contribution_status_id' => '1',
140 'honor_type_id' => '',
142 'check_number' => '',
144 'contribution_type_id' => '1',
148 'api.website.create' => array(
158 'url' => 'http://civicrm.org',
159 'website_type_id' => '',
172 'url' => 'http://chained.org',
173 'website_type_id' => '2',
182 return $expectedResult;
187 * This example has been generated from the API test suite. The test that created it is called
189 * testCreateIndividualWithContributionChainedArrays and can be found in
190 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
192 * You can see the outcome of the API tests at
193 * https://test.civicrm.org/job/CiviCRM-master-git/
195 * To Learn about the API read
196 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
198 * Browse the api on your own site with the api explorer
199 * http://MYSITE.ORG/path/to/civicrm/api/explorer
201 * Read more about testing here
202 * http://wiki.civicrm.org/confluence/display/CRM/Testing
204 * API Standards documentation:
205 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards