<?php
-
-/*
- This demonstrates use of the 'format.single_value' param.
+/**
+ * Test Generated example of using contact getvalue API
+ * This demonstrates use of the 'format.single_value' param.
/* This param causes only a single value of the only entity to be returned as an string.
- /* it will be ignored if there is not exactly 1 result
+ /* it will be ignored if there is not exactly 1 result *
*/
function contact_getvalue_example(){
-$params = array(
- 'version' => 3,
+$params = array(
'id' => 17,
'return' => 'display_name',
);
- $result = civicrm_api( 'contact','getvalue',$params );
+try{
+ $result = civicrm_api3('contact', 'getvalue', $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 contact_getvalue_expectedresult(){
$expectedResult = 'Test Contact';
- return $expectedResult ;
+ return $expectedResult;
}
*
* API Standards documentation:
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/