updated examples
[civicrm-core.git] / api / v3 / examples / MailSettingsGet.php
index c5090886c51315c0a0c9395c15f870bbb4618d56..881dec97c739c7d72ea91c5a06d3e72140b97c3a 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using mail_settings get API
+ * *
  */
 function mail_settings_get_example(){
 $params = array(
@@ -12,15 +12,23 @@ $params = array(
   'server' => 'localhost',
   'username' => 'sue',
   'password' => 'pass',
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'mail_settings','get',$params );
+try{
+  $result = civicrm_api3('mail_settings', '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 mail_settings_get_expectedresult(){
@@ -45,7 +53,7 @@ function mail_settings_get_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -69,4 +77,4 @@ function mail_settings_get_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/