3 * Test Generated example demonstrating the Campaign.create API.
5 * Create a campaign - Note use of relative dates here:
6 * @link http://www.php.net/manual/en/datetime.formats.relative.php.
11 function campaign_create_example() {
13 'title' => 'campaign title',
14 'description' => 'Call people, ask for money',
15 'created_date' => 'first sat of July 2008',
19 $result = civicrm_api3('Campaign', 'create', $params);
21 catch (CiviCRM_API3_Exception
$e) {
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
28 'error_message' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
38 * Function returns array of result expected from previous function.
43 function campaign_create_expectedresult() {
45 $expectedResult = array(
53 'name' => 'campaign_title',
54 'title' => 'campaign title',
55 'description' => 'Call people, ask for money',
58 'campaign_type_id' => '',
60 'external_identifier' => '',
64 'created_date' => '2013-07-28 08:49:19',
65 'last_modified_id' => '',
66 'last_modified_date' => '',
73 return $expectedResult;
77 * This example has been generated from the API test suite.
78 * The test that created it is called "testCreateCampaign"
79 * and can be found at:
80 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CampaignTest.php
82 * You can see the outcome of the API tests at
83 * https://test.civicrm.org/job/CiviCRM-master-git/
85 * To Learn about the API read
86 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
88 * Browse the api on your own site with the api explorer
89 * http://MYSITE.ORG/path/to/civicrm/api
91 * Read more about testing here
92 * http://wiki.civicrm.org/confluence/display/CRM/Testing
94 * API Standards documentation:
95 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards