updated examples
[civicrm-core.git] / api / v3 / examples / OptionValueGet.php
index dbce441a53da0f8b605dc8f6c792c69b779b9468..5490d6c3b912ec900de356a5ed93bfdbdbe0fdfa 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using option_value get API
+ * *
  */
 function option_value_get_example(){
 $params = array(
   'option_group_id' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'option_value','get',$params );
+try{
+  $result = civicrm_api3('option_value', '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 option_value_get_expectedresult(){
@@ -82,7 +90,7 @@ function option_value_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -106,4 +114,4 @@ function option_value_get_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/