CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Using api v3
Pages: [1]

Author Topic: Using api v3  (Read 622 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Using api v3
March 08, 2011, 11:11:40 am
I backported API3 onto our 3.3.5 codebase yesterday and used it for the first time in a module

Once I took a look at what I had writted I realised that the first thing I had done was write a wrapper! The wrapper is effectively what Andreas suggested in an e-mail - adding a 'GetByID' action. It now seems to me it might be good to add this now. Beyond the fact that it seems really useful once you actually start using the API I can see a couple of other advantages:

1) The update API could call it & any handling for the 'id' vs 'entity_id' (if required) could be managed by it.
2) We could add a test for it in the APIStandards test class & identify any API which DON'T take 'id' for GET


Code: [Select]
/*
 * Get contact Details out of CiviCRM
 */

function getContactDetailsFromCivi($contactID){
  require_once 'api/api.php';
  $params = array('id'  => $contactID,
                   'version'  => 3,);
  $contact = civicrm_api('Contact', 'Get', $params);
  return($contact['values'][$contact['id']]);
 
}
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Using api v3
March 11, 2011, 02:48:41 am
Definitely having the id that works all the time would be a big big plus.

(testing both for the get and create/update).

With that, we got the modify action for free (ready, but only work if the same key works all the time for both get and create)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Using api v3

This forum was archived on 2017-11-26.