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) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Civix, API function not showing up on live site
Pages: [1]

Author Topic: Civix, API function not showing up on live site  (Read 1264 times)

denishow

  • I’m new here
  • *
  • Posts: 19
  • Karma: 2
  • CiviCRM version: 4.2
  • CMS version: WordPress 3.4.2
  • MySQL version: 5.4
  • PHP version: 5.3.15
Civix, API function not showing up on live site
December 07, 2012, 09:57:23 am
Hi,

I've used Civix to create a few pages and an API function (Contribution -> findbydate which returns all the contributions for a particular individual on a specified date).

It all works fine on my dev machine (Mac OS X Mountain Lion), but when I deploy it to the live server, the pages work fine, but it says it can't find the findbydate API function.

Have I forgotten a step? Do I need to make the live site re-index and find the command? I've googled the instructions but can't find anything. I've also checked to see if there's a case sensitivity issue, but now I've made it so that the file and code are all in lower case, but it still doesn't work.

Can anyone point me in the right direction?

Thanks
Denis

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Civix, API function not showing up on live site
December 07, 2012, 11:15:16 am
A couple thoughts:

 * The API infrastructure does a few different manipulations based on capitalization. They're not entirely consistent, but they have some workable combinations. Have you tried using:
  + File: "api/v3/Contribution/Findbydate.php"
  + Function: "civicrm_api3_contribution_findbydate"
  + Invocation: civicrm_api("Contribution", "findbydate", ...)

* There was a bug in earlier releases of 4.2 which caused the API-explorer (and similar tools) to not display

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Civix, API function not showing up on live site
December 08, 2012, 01:37:34 am
Hi,

For reference, what os do you have on the production server?

As a side note, the convention is to use getXXX instead of find. It probably doesn't make any difference in your case, but they are some security control so you can't call any action that isn't a getXXX over HTTP GET if you use the REST or Ajax (but POST works fine).

And we are introducing soon a more strict default security on custom api for REST and Ajax too, so if you were to use your new api like this, you would need to implement the hook alterAPIPermissions
http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hook_civicrm_alterAPIPermissions

Lastly, as more folks seems to start creating custom apis, I'd like to make it easier to share them or at least to inform there is one to avoid nameclashes. A simple wiki page or something more elaborate? Suggestions welcome

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

denishow

  • I’m new here
  • *
  • Posts: 19
  • Karma: 2
  • CiviCRM version: 4.2
  • CMS version: WordPress 3.4.2
  • MySQL version: 5.4
  • PHP version: 5.3.15
Re: Civix, API function not showing up on live site
December 10, 2012, 07:36:31 am
Hi both,

Thanks for this!

The capitalisation was the problem. I simply renamed the file api/v3/Contribution/Findbydate.php and it worked (I had tried findbydate and FindByDate without luck).

I'm afraid I'm not sure what flavour of Unix I have on the production server, it's a shared hosting environment and I haven't got ssh access, so not quite sure how to find out (apart from raising a support call).

I take your point about the convention being to use getXXX and will consider renaming. Maybe in fact there's a neater way to do it?

I'm currently using Ajax to check if a Contribution has already been added for a certain individual, contribution type and date, so I want to query all the existing contributions for an individual that fall inside the 24 hours of the specified day (in fact most of my contributions don't have a time associated with them).

Is there an existing API call that I could use?

I've tried

"Contribution","get", array (version => '3','page' =>'CiviCRM', 'q' =>'civicrm/ajax/rest', 'sequential' =>'1', 'receive_date' =>'201211280000')

But this falls over with a fatal error complaining about the date. I've tried every format I could think of without any success (and anyway as I say, I need to be able to provide a time span rather than a precise date and time).

Thanks loads for the help
Denis

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Civix, API function not showing up on live site
December 10, 2012, 10:40:11 am
Several months ago, Eileen worked on supporting BETWEEN in some situations, like:

http://svn.civicrm.org/civicrm/branches/v4.2/api/v3/examples/Relationship/BetweenRelationshipType.php

I don't know if it'll work in this case, but it's probably worth a try.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Civix, API function not showing up on live site
December 11, 2012, 07:56:39 pm
Contribution GET api leverages the Query object. I expect it will take criteria like 'receive_date_low' - look in CRM_Contact_BAO_Query & search for 'high' or 'low'.

Because these pseudofields aren't defined in getfields it will expect an SQL style date. (they could reasonably be patched into getfields)
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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Civix, API function not showing up on live site

This forum was archived on 2017-11-26.