test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / ContactGet.php
index b4dc0bbe9adab3a2e2188e5476503a39814dc09a..5b6cd352edf95e050663b69e2891f854c740842b 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(){
@@ -65,10 +73,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 +85,15 @@ function contact_get_expectedresult(){
           'im' => '',
           'worldregion_id' => '',
           'world_region' => '',
+          'state_province_name' => '',
+          'state_province' => '',
+          'country' => '',
           'id' => '1',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }