<?php
/**
- * @file
- * Test Generated API Example.
- * See bottom of this file for more detail.
- */
-
-/**
- * Test Generated example of using contact create API.
+ * Test Generated example demonstrating the Contact.create API.
*
- * /*this demonstrates the usage of chained api functions. Specifically it has one 'parent function' &
- 2 child functions - one receives values from the parent (Contact) and the other child (Tag).
+ * This demonstrates the usage of chained api functions. Specifically it has one 'parent function' &
+ * 2 child functions - one receives values from the parent (Contact) and the other child (Tag).
*
* @return array
* API result array
);
try{
- $result = civicrm_api3('contact', 'create', $params);
+ $result = civicrm_api3('Contact', 'create', $params);
}
catch (CiviCRM_API3_Exception $e) {
// Handle error here.
$errorCode = $e->getErrorCode();
$errorData = $e->getExtraParams();
return array(
- 'error' => $errorMessage,
+ 'is_error' => 1,
+ 'error_message' => $errorMessage,
'error_code' => $errorCode,
'error_data' => $errorData,
);
'is_error' => 0,
'version' => 3,
'count' => 1,
- 'id' => 1,
+ 'id' => 3,
'values' => array(
- '1' => array(
- 'id' => '1',
+ '3' => array(
+ 'id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
'do_not_email' => 0,
'is_opt_out' => 0,
'legal_identifier' => '',
'external_identifier' => '',
- 'sort_name' => '',
+ 'sort_name' => 'batman',
'display_name' => 'batman',
'nick_name' => '',
'legal_name' => '',
return $expectedResult;
}
-/**
+/*
* This example has been generated from the API test suite.
-* The test that created it is called
-* testChainingValuesCreate
-* and can be found in
+* The test that created it is called "testChainingValuesCreate"
+* and can be found at:
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
*
* You can see the outcome of the API tests at
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
*
* Browse the api on your own site with the api explorer
-* http://MYSITE.ORG/path/to/civicrm/api/explorer
+* http://MYSITE.ORG/path/to/civicrm/api
*
* Read more about testing here
* http://wiki.civicrm.org/confluence/display/CRM/Testing