X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Fexamples%2FMailSettingsCreate.php;h=072e60d2a533e17a5334787cb94e3ca64fe3e8c9;hb=7fbb4198d03adaf0b536941641b438103998efa3;hp=d4f31734716be26807273842327dabbd75de8d23;hpb=6a4880350680e1e4d20e5c8a622a791f926ca750;p=civicrm-core.git diff --git a/api/v3/examples/MailSettingsCreate.php b/api/v3/examples/MailSettingsCreate.php index d4f3173471..072e60d2a5 100644 --- a/api/v3/examples/MailSettingsCreate.php +++ b/api/v3/examples/MailSettingsCreate.php @@ -1,10 +1,10 @@ 1, 'name' => 'my mail setting', 'domain' => 'setting.com', @@ -12,26 +12,34 @@ $params = array( 'server' => 'localhost', 'username' => 'sue', 'password' => 'pass', - 'version' => 3, ); - $result = civicrm_api( 'mail_settings','create',$params ); +try{ + $result = civicrm_api3('mail_settings', 'create', $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_create_expectedresult(){ - $expectedResult = array( + $expectedResult = array( 'is_error' => 0, 'version' => 3, 'count' => 1, 'id' => 2, - 'values' => array( - '2' => array( + 'values' => array( + '2' => array( 'id' => '2', 'domain_id' => '1', 'name' => 'my mail setting', @@ -50,7 +58,7 @@ function mail_settings_create_expectedresult(){ ), ); - return $expectedResult ; + return $expectedResult; }