Merge pull request #5020 from pratikshad/4.6-alpha4
[civicrm-core.git] / api / v3 / examples / Contact / FormatIsSuccess_True.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
50fb255d 3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6 */
7
8/**
9 * Test Generated example of using contact get API.
10 *
fb32de45 11 * This demonstrates use of the 'format.is_success' param.
50fb255d 12 This param causes only the success or otherwise of the function to be returned as BOOLEAN
13 *
14 * @return array
15 * API result array
6a488035 16 */
50fb255d 17function contact_get_example() {
18 $params = array(
19 'id' => 17,
20 'format.is_success' => 1,
21 );
6a488035 22
50fb255d 23 try{
24 $result = civicrm_api3('contact', 'get', $params);
25 }
26 catch (CiviCRM_API3_Exception $e) {
27 // Handle error here.
28 $errorMessage = $e->getMessage();
29 $errorCode = $e->getErrorCode();
30 $errorData = $e->getExtraParams();
31 return array(
32 'error' => $errorMessage,
33 'error_code' => $errorCode,
34 'error_data' => $errorData,
35 );
36 }
6a488035 37
50fb255d 38 return $result;
6a488035
TO
39}
40
fb32de45 41/**
50fb255d 42 * Function returns array of result expected from previous function.
43 *
44 * @return array
45 * API result array
6a488035 46 */
50fb255d 47function contact_get_expectedresult() {
6a488035
TO
48
49 $expectedResult = 1;
50
fb32de45 51 return $expectedResult;
6a488035
TO
52}
53
50fb255d 54/**
55* This example has been generated from the API test suite.
56* The test that created it is called
57* testContactGetFormatIsSuccessTrue
58* and can be found in
69d79249 59* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
6a488035
TO
60*
61* You can see the outcome of the API tests at
69d79249 62* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
63*
64* To Learn about the API read
69d79249 65* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 66*
69d79249
E
67* Browse the api on your own site with the api explorer
68* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
69*
70* Read more about testing here
71* http://wiki.civicrm.org/confluence/display/CRM/Testing
72*
73* API Standards documentation:
74* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 75*/