updated examples
[civicrm-core.git] / api / v3 / examples / ContactGet.php
index b4dc0bbe9adab3a2e2188e5476503a39814dc09a..7101dbfe2e84b4412b6abd731dd2a64057535804 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using contact get API
+ * *
  */
 function contact_get_example(){
 $params = array(
   'email' => 'man2@yahoo.com',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'contact','get',$params );
+try{
+  $result = civicrm_api3('contact', 'get', $params);
+}
+catch (CiviCRM_API3_Exception $e) {
+  // handle error here
+  $errorMessage = $e->getMessage();
+  $errorCode = $e->getErrorCode();
+  $errorData = $e->getExtraParams();
+  return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
 
-  return $result;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function contact_get_expectedresult(){
@@ -42,11 +50,16 @@ function contact_get_expectedresult(){
           'nick_name' => '',
           'legal_name' => '',
           'image_URL' => '',
+          'preferred_communication_method' => '',
+          'preferred_language' => 'en_US',
           'preferred_mail_format' => 'Both',
           'first_name' => '',
           'middle_name' => '',
           'last_name' => '',
+          'prefix_id' => '',
+          'suffix_id' => '',
           'job_title' => '',
+          'gender_id' => '',
           'birth_date' => '',
           'is_deceased' => 0,
           'deceased_date' => '',
@@ -65,10 +78,7 @@ function contact_get_expectedresult(){
           'geo_code_1' => '',
           'geo_code_2' => '',
           'state_province_id' => '',
-          'state_province_name' => '',
-          'state_province' => '',
           'country_id' => '',
-          'country' => '',
           'phone_id' => '',
           'phone_type_id' => '',
           'phone' => '',
@@ -80,12 +90,18 @@ function contact_get_expectedresult(){
           'im' => '',
           'worldregion_id' => '',
           'world_region' => '',
+          'individual_prefix' => '',
+          'individual_suffix' => '',
+          'gender' => '',
+          'state_province_name' => '',
+          'state_province' => '',
+          'country' => '',
           'id' => '1',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -109,4 +125,4 @@ function contact_get_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/