updated examples
[civicrm-core.git] / api / v3 / examples / AddressCreate.php
index 4a5a6480076b968513dde8d81686064092127209..c60211fbc6732b660a5e7c768ff844d0bd25368d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using address create API
+ * *
  */
 function address_create_example(){
 $params = array(
@@ -14,15 +14,23 @@ $params = array(
   'country_id' => '1152',
   'city' => 'Brummen',
   'is_primary' => 1,
-  'version' => 3,
 );
 
-  $result = civicrm_api( 'address','create',$params );
+try{
+  $result = civicrm_api3('address', '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 address_create_expectedresult(){
@@ -50,7 +58,7 @@ function address_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -74,4 +82,4 @@ function address_create_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/