CRM-13072 Update examples
[civicrm-core.git] / api / v3 / examples / PhoneCreate.php
index c6c79295f3a385968e76596974a633c06f847ed0..7a2b6c860423b1b6f68c10e205d63ba9abc21d0b 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using phone create API
+ * *
  */
 function phone_create_example(){
 $params = array(
@@ -9,16 +9,24 @@ $params = array(
   'location_type_id' => 6,
   'phone' => '(123) 456-7890',
   'is_primary' => 1,
-  'version' => 3,
   'phone_type_id' => 1,
 );
 
-  $result = civicrm_api( 'phone','create',$params );
+try{
+  $result = civicrm_api3('phone', '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 phone_create_expectedresult(){
@@ -44,7 +52,7 @@ function phone_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }