Apiv4 documentation
Created by: seamuslee001
This incoporates https://github.com/civicrm/civicrm-dev-docs/pull/689/files
Merge request reports
Activity
173 Using the CRM.api3 method you can pass multiple requests through at once e.g. 174 175 ```javascript 176 var params = [ 177 ['email', 'get', {contact_id: 123}], 178 ['phone', 'get', {phone: '555-5555'}] 179 ]; 180 CRM.api3(params).done(function(result) { 181 console.log('email result is:', result[0]); 182 console.log('phone result is:', result[1]); 183 }); 184 ``` 185 186 You can also use associative objects in your API call as follows: 187 188 ``` 67 ]); 68 } 69 catch (\API_Exception $e) { 70 $error = $e->getMessage(); 71 } 72 printf("Found %d item(s)\n", count($contacts)); 73 ``` 74 75 This format matches canonical format almost exactly, with a few improvements for usability: 76 77 The `version => 4` parameter is not required. 78 Errors are reported as PHP exceptions. You may catch the exceptions or (by default) allow them to bubble up. 79 You can immediately iterate over the contacts returned 80 81 *Note*: If you're writing a Drupal module, a Joomla extension, a WordPress plugin, or a standalone script, then you may need to **bootstrap** CiviCRM before using the API. See the examples in [Bootstrap Reference]. 82
Please register or sign in to reply