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) »
  • Is there a problem in the wordpress API code?
Pages: [1]

Author Topic: Is there a problem in the wordpress API code?  (Read 756 times)

ldgpangeo

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: drupal-7.17
  • MySQL version: 5.5.23
  • PHP version: 5.3.13
Is there a problem in the wordpress API code?
January 27, 2015, 07:19:45 am
I'm encountering an odd situation an am not sure if it's me or a bug in the civicrm code.

I'm trying to use the API's to retrieve information from Civi for integration into a php app that I'm developing.  I'm finding the following situation.

Calling the API for notes works fine for both Drupal and Wordpress instances for CiviCRM
 $result = civicrm_api3('Note', 'get', array('sequential' => 1,'id' => 37,));

Calling the API for contacts works for Drupal but NOT for Wordpress
$result = civicrm_api3('Contact', 'get', array('sequential' => 1,'last_name' => "Geoffrion",));
   Drupal returns the contact info for the person with that last name (me)
   Wordpress returns nothing -- no data and no error message.

Both Civicrm instances are running 4.5.4 code and their contents are essentially the same since we are working on transitioning the site from Drupal to WordPress.  The php code I am running is identical.  I just change the one line you see above.

Is anyone else experiencing a similar API problem with WordPress Civicrm?

Is this a known limitation of the WordPress instance or should this be reported as a bug?
(e.g. I know that WP's support for hooks is more limited than in Drupal)



Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Is there a problem in the wordpress API code?
January 27, 2015, 07:30:21 am
Have you tried it on http://wp45.demo.civicrm.org/wp-admin/admin.php?page=CiviCRM&q=civicrm/api/explorer
Try asking your question on the new CiviCRM help site.

ldgpangeo

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: drupal-7.17
  • MySQL version: 5.5.23
  • PHP version: 5.3.13
Re: Is there a problem in the wordpress API code?
January 27, 2015, 07:34:39 am
Yes,   I found that helpful in setting the parameters.

That looks like it might be a Drupal-based instance, however.

Whatever is going on, it's specific to the contact portion of the WordPress API.  It works as expected if I use the API to retrieve note, email, or address information.


JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Is there a problem in the wordpress API code?
January 27, 2015, 08:28:58 am
The link Coleman gave is to the Wordpress-based instance of Civi 4.5.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

ldgpangeo

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: drupal-7.17
  • MySQL version: 5.5.23
  • PHP version: 5.3.13
Re: Is there a problem in the wordpress API code?
January 27, 2015, 10:14:17 am
Thanks.    Interesting, it works there with no problem.

I have two WP Civi instances running on different hosts with different data.   Both show the same pattern WRT failing for contacts but working fine for everything else.  In both, the normal Civi work done via the web pages works fine.

Any suggestions for what I should be chasing down to find out why there is this selective error?

ldgpangeo

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: drupal-7.17
  • MySQL version: 5.5.23
  • PHP version: 5.3.13
Re: Is there a problem in the wordpress API code?
January 27, 2015, 10:44:40 am
I've pretty much confirmed that the problem is mine -- not anything in the civicrm code.

Now, to figure out what I'm doing wrong and why it's specific to contact searches.

Thanks for pointing me to that other demo site.   


ldgpangeo

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 0
  • CiviCRM version: 4.2.6
  • CMS version: drupal-7.17
  • MySQL version: 5.5.23
  • PHP version: 5.3.13
Re: Is there a problem in the wordpress API code?
January 27, 2015, 05:17:26 pm
BTW...   Here's the fix...

Two constants must be defined:
define('ABSPATH' , "/web/wordpress/");   <--  place here the path to your WordPress installation
define('WPINC' , "wp-includes");     <-- this only needs to change if you've renamed the includes directory

Apparently, the contact lookup needs to include code from the wp-includes directory, while the other searches do not need it.

It might be worth adding this type of info to the documentation -- including the corresponding adjustments for the other CMS's. 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Is there a problem in the wordpress API code?

This forum was archived on 2017-11-26.