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) »
  • Status API v3 in CiviCRM 3.4 (all API users please take note!!)
Pages: [1]

Author Topic: Status API v3 in CiviCRM 3.4 (all API users please take note!!)  (Read 739 times)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Status API v3 in CiviCRM 3.4 (all API users please take note!!)
January 14, 2011, 07:04:04 am
This morning (at least in my timezone, for one of us it was evening) we (Eileen, Piotr, Xavier, Michal for some of it and me) had a meeting about the work to be done to get the v3 version of the API out with CiviCRM 3.4. For those of you that are not aware of this, we are making some standardization improvements to the API. Because of backward compatibilty issues we are creating a v3 API, so people can still use the current v2 version for some time.

We decided to create a wiki page that will contain instructions on what has to be done to migrate an API to v3 (will be anounced shortly by Xavier) and a wiki page which lists the API's and functions, where everyone can list their name against an API / function that they are willing to migrate, ideally before Feb 9 2011 (code freeze date for CiviCRM 3.4). So all of you that want to get involved, watch this space and the wiki for further instructions. Your help will be VERY appreciated and is necessary to get the improvements we would like, in the coming weeks and in the future. We can certainly use all the help we can get and more!  ;D

This post is also a request to let the API team know what you need to get involved and lend a hand. We would like as many of you out there involved as possible, and we want to help you to get stuck in! So let us know....


In CiviCRM 3.4 there will be an api.php in the api folder that allows you to call every API with a version parameter. It will look something like this:
Code: [Select]
function civicrm_api($function, $class, $params){
if (empty($params['version'])){
 $params['version'] = 2;
}

require_once 'api/v' . $params['version'] . '/' . $class .'.php';
$result = $function($params);
return $result;
}

That will allow you to call the api in version 3 or in version 2 mode. So if you want to a civicrm_contact_create and want to use the v2 api, the call will be:

Code: [Select]
$result = civicrm_api( 'civicrm_contact_create','Contact',$params );
In your $params you set the version parameter to hold the version you want, where the current v2 is the default.

Erik (as a member of the API team)
« Last Edit: January 14, 2011, 07:06:28 am by Erik Hommel »
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

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: Status API v3 in CiviCRM 3.4 (all API users please take note!!)
January 14, 2011, 08:03:47 am

in general for such "generic" functions, u'll need to sanitize and check the validity of all the parameters

check CRM/Utils/REST.php, function process for some cleaning tips :)

specifically do ensure that:

1. version is a number

2. $class has been sanitized and has no funny characters (like eval's and function calls)

3. $params is an array

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

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Status API v3 in CiviCRM 3.4 (all API users please take note!!)
January 14, 2011, 08:05:22 am
Yep, that was discussed and will be done ;)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Status API v3 in CiviCRM 3.4 (all API users please take note!!)
January 17, 2011, 10:09:59 am

I did some type checking an cleaning

suggestion to be like crmAPI:

civicrm_api ($entity, $action, $param) {
$function= "civicrm_$entity_$action)

instead of :

function civicrm_api($function, $class, $params){

Beside, we don't need class (check REST.php) that's built directly from the function name too IMO

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) »
  • Status API v3 in CiviCRM 3.4 (all API users please take note!!)

This forum was archived on 2017-11-26.