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 (Moderator: Donald Lobo) »
  • using v2 APIs from external modules
Pages: [1]

Author Topic: using v2 APIs from external modules  (Read 1843 times)

chrism

  • Guest
using v2 APIs from external modules
March 20, 2008, 02:16:13 am
While looking into upgrading the Drupal CiviCRM Subscriptions module (http://drupal.org/node/234066) to use v2 APIs I had to hack some CiviCRM core code so I've either missed something or there's a bug.

- The first change needed in civicrm_subscribe.module is that crm_get_group is changed to civicrm_groups_get
- However calling civicrm_groups_get returns an error because it is not found despite a call to civicrm_initialize
- I added 'require_once 'api/v2/Group.php';' to civicrm_initialize() to allow the function to be called in the external module.

In CiviCRM 1.9, civicrm_initialize took an argument of api_required and if it was true then api/crm.php was called to include all APIs.  In CiviCRM 2.0 the api_required argument was removed and there is not file similar to crm.php that can be used to include all the v2 apis. Without the option to include APIs in  civicrm_initialize how should the API's be called from an external module?



Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: using v2 APIs from external modules
March 20, 2008, 07:20:59 am

People should require the specific api files they need. Including all the api files (like crm.php) loads way more files than needed

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

chrism

  • Guest
Re: using v2 APIs from external modules
March 20, 2008, 06:34:38 pm
OK, thanks.  I thought there might have been a preferred way that folks had to keep the civicrm module's directory structure abstracted but requiring "api/v2/Group.php" for instance is straightforward.   

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • using v2 APIs from external modules

This forum was archived on 2017-11-26.