Merge branch 'master' of https://github.com/civicrm/civicrm-core into labels
[civicrm-core.git] / api / v3 / examples / ProfileGet.php
1 <?php
2 /**
3 * Test Generated example of using profile get API
4 * *
5 */
6 function profile_get_example(){
7 $params = array(
8 'profile_id' => array(
9 '0' => 25,
10 '1' => 1,
11 '2' => 'Billing',
12 ),
13 'contact_id' => 1,
14 );
15
16 try{
17 $result = civicrm_api3('profile', 'get', $params);
18 }
19 catch (CiviCRM_API3_Exception $e) {
20 // handle error here
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
25 }
26
27 return $result;
28 }
29
30 /**
31 * Function returns array of result expected from previous function
32 */
33 function profile_get_expectedresult(){
34
35 $expectedResult = array(
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 3,
39 'values' => array(
40 '25' => array(
41 'first_name' => 'abc1',
42 'last_name' => 'xyz1',
43 'email-Primary' => 'abc1.xyz1@yahoo.com',
44 'phone-1-1' => '021 512 755',
45 'country-1' => '1228',
46 'state_province-1' => '1021',
47 'postal_code-1' => '90210',
48 ),
49 '1' => array(
50 'first_name' => 'abc1',
51 'last_name' => 'xyz1',
52 'street_address-1' => '5 Saint Helier St',
53 'city-1' => 'Gotham City',
54 'postal_code-1' => '90210',
55 'country-1' => '1228',
56 'state_province-1' => '1021',
57 ),
58 'Billing' => array(
59 'billing_first_name' => 'abc1',
60 'billing_middle_name' => 'J.',
61 'billing_last_name' => 'xyz1',
62 'billing_street_address-5' => '5 Saint Helier St',
63 'billing_city-5' => 'Gotham City',
64 'billing_state_province_id-5' => '1021',
65 'billing_country_id-5' => '1228',
66 'billing_postal_code-5' => '90210',
67 'billing-email-5' => 'abc1.xyz1@yahoo.com',
68 'email-5' => 'abc1.xyz1@yahoo.com',
69 ),
70 ),
71 );
72
73 return $expectedResult;
74 }
75
76
77 /*
78 * This example has been generated from the API test suite. The test that created it is called
79 *
80 * testProfileGetMultiple and can be found in
81 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ProfileTest.php
82 *
83 * You can see the outcome of the API tests at
84 * http://tests.dev.civicrm.org/trunk/results-api_v3
85 *
86 * To Learn about the API read
87 * http://book.civicrm.org/developer/current/techniques/api/
88 *
89 * and review the wiki at
90 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
91 *
92 * Read more about testing here
93 * http://wiki.civicrm.org/confluence/display/CRM/Testing
94 *
95 * API Standards documentation:
96 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
97 */