X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Fexamples%2FProfileApply.php;h=24368a7dd57f9049b2f5eb1b1e88a9044f5cd1a5;hb=4d32d50b462d76a14faf7a6f732816ee9fe40ee6;hp=0363c2a3ca180e53b925e667091dfd4d5fde9243;hpb=ab28144e2f83e8ab33a4d6d60cd5e6dd3d9184eb;p=civicrm-core.git diff --git a/api/v3/examples/ProfileApply.php b/api/v3/examples/ProfileApply.php index 0363c2a3ca..24368a7dd5 100644 --- a/api/v3/examples/ProfileApply.php +++ b/api/v3/examples/ProfileApply.php @@ -1,13 +1,12 @@ 25, 'contact_id' => 1, - 'version' => 3, 'first_name' => 'abc2', 'last_name' => 'xyz2', 'email-Primary' => 'abc2.xyz2@gmail.com', @@ -16,12 +15,21 @@ $params = array( 'state_province-1' => '1000', ); - $result = civicrm_api( 'profile','apply',$params ); +try{ + $result = civicrm_api3('profile', 'apply', $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 profile_apply_expectedresult(){ @@ -29,13 +37,14 @@ function profile_apply_expectedresult(){ $expectedResult = array( 'is_error' => 0, 'version' => 3, - 'count' => 10, + 'count' => 11, 'values' => array( 'contact_type' => 'Individual', 'contact_sub_type' => '', 'contact_id' => 1, - 'profile_id' => 25, 'version' => 3, + 'debug' => 1, + 'profile_id' => 25, 'first_name' => 'abc2', 'last_name' => 'xyz2', 'email' => array( @@ -64,7 +73,7 @@ function profile_apply_expectedresult(){ ), ); - return $expectedResult ; + return $expectedResult; }