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) »
  • Drupal, PHP, API - what am I missing ?
Pages: [1]

Author Topic: Drupal, PHP, API - what am I missing ?  (Read 565 times)

pike67

  • I post occasionally
  • **
  • Posts: 55
  • Karma: 0
  • CMS version: drupal7
Drupal, PHP, API - what am I missing ?
June 21, 2012, 07:20:38 am
Hi

This is my first attempt at the API - am I doing something terribly wrong ?
Straight from the manual, i try, from inside a Drupal module,

Quote
require_once '/my_wild_path_to/civicrm/api/api.php';
$result = civicrm_api ($entity,$action,$params);

but no ? already inside api.php, all requires() and includes() are written relative, and assume
you are located in the civicrm folder. so I have to chdir there, and back, and everytime I call a
function, chdir there again - and back when done. Is that correct ?

But even if I do, it all ends in a
Quote
Failed opening required 'DB/DataObject.php' (include_path='.:/usr/local/lib/php') in /my_wild_path_to/civicrm/CRM/Core/DAO.php

it seems DB/DataObject.php is in civicrm/packages - so that path is all wrong. strange ?
should i try the old api instead ?

*pike



« Last Edit: June 21, 2012, 01:16:35 pm by pike67 »

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Php API - what am I missing ?
June 21, 2012, 11:04:42 am
Hi,

You are not supposed to require api.php

The "normal" way from within drupal is

Code: [Select]
civicrm_initialize();
civicrm_api (... bla bla bla);

Can you try adding civicrm_initialize() and then calling civicrm_api ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

pike67

  • I post occasionally
  • **
  • Posts: 55
  • Karma: 0
  • CMS version: drupal7
Re: Php API - what am I missing ?
June 21, 2012, 01:16:06 pm
Instant Gratification!  ;D  thanks Xavier.

ok, so .. was I looking at the wrong docs ? I just just monkeywise went
here http://book.civicrm.org/developer/techniques/api and then here
http://wiki.civicrm.org/confluence/display/CRMDOC41/CiviCRM+Public+APIs .

is there a special drupal+civi doc somewhere ?

thanks,
*-pike

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Drupal, PHP, API - what am I missing ?

This forum was archived on 2017-11-26.