Merge pull request #2288 from eileenmcnaughton/CRM-14043
[civicrm-core.git] / api / v3 / examples / UFMatchGet.php
index 2a34f210bf0036567ac6023fc38a47e5ce2fbc76..2e664f4be6b3d93da15a7fd27420d547ff6b1962 100644 (file)
@@ -1,31 +1,39 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using uf_match get API
+ * *
  */
 function uf_match_get_example(){
-$params = array( 
+$params = array(
   'contact_id' => 69,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'uf_match','get',$params );
+try{
+  $result = civicrm_api3('uf_match', '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 uf_match_get_expectedresult(){
 
-  $expectedResult = array( 
+  $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
   'id' => 1,
-  'values' => array( 
-      '1' => array( 
+  'values' => array(
+      '1' => array(
           'id' => '1',
           'domain_id' => '1',
           'uf_id' => '42',
@@ -34,7 +42,7 @@ function uf_match_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }