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