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) »
  • REST API Library...finally
Pages: [1]

Author Topic: REST API Library...finally  (Read 4512 times)

acrosman

  • Guest
REST API Library...finally
April 24, 2009, 05:07:59 pm
Months and months ago I promised to deliver a PHP library to work with the REST API.  I finally have a draft of one that's ready to share.  It should work with 2.1 and 2.2, although I've only been testing against the svn tree for 2.2.  I've posted a tarball on one of AFSC's servers:
http://tools.afsc.org/libraries/civicrm_php_lib.tar.gz

There is a README file included that I think explains how to use the library, but since I'm the only user so far I don't know how clear it is if you're not me.  I've also included a sample page that makes a couple of call so you can see how I think it should work.

Right now the library is fairly basic.  I went with flexibility of features, so it while it will allow you to call any function in the Public API, it does not have good wrappers for all the functions instead I provide one catch all the makes it easy to call anything.  Once I've got a little more experience with it, and hopefully have some other feedback, I'll extend it further to be more helpful.  It does have built in functions to call the ping and login functions that are part of the REST interface, that aren't a standard part of the API (the README talks about when to use login).

If you're a PHP programmer, and wanting to work with the REST interface, it would be great if you could give this a try and let me know how it works for you.  I'd love to get some feedback on ways to make the library and the REST interface itself for that matter.

ijames

  • Guest
Re: REST API Library...finally
December 18, 2009, 02:05:26 am
Hey there!

Is there something newer than this out there?  I'm on CiviCRM 3.0.2 and the login doesn't seem to want to give me an API key, also I don't know where to look for a key on the drupal users or contacts, or ?

Suggestions on how to start getting a CIVICRM REST API going on 3.0.2?

Thanks!

James

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: REST API Library...finally
December 20, 2009, 01:31:49 am
http://wiki.civicrm.org/confluence/display/CRMDOC/REST+interface

As for the key
http://wiki.civicrm.org/confluence/display/CRMDOC/Command-line+Script+Configuration

Does it help ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

jrburcher

  • Guest
Re: REST API Library...finally
April 25, 2010, 05:55:40 pm
Hi,

I have looked through the doc that was created and am having an issue actually creating the API users.  In the doc, I am upto:-
and then login each API user account once before restoring the commenting of these lines to their original state.

Does anyone know how to create the API users?  I can't figure it out

Thank you so much! :)

jrburcher

  • Guest
Re: REST API Library...finally
April 25, 2010, 06:28:43 pm
For anyone else trying to get this working, I found that if you set the api_key manually through phpmyadmin / webmin / whatever the code then becomes:-
http://domain/extern/rest.php?q=civicrm/contact/search&key=[key]&api_key=[key]

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: REST API Library...finally
April 26, 2010, 09:44:00 am
Great that you did manage.

Could you update the wiki to clarify ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

hesco

  • Guest
Re: REST API Library...finally
September 08, 2010, 01:04:50 pm
to Xavier's question, what I did to follow this advise was to run an
UPDATE civicrm_contact SET api_key = $my_key WHERE id = ?;

I used my pwgen tool to create a 32 bit key, plugged it into both
the database (for my user) and into my REST api scripts.

While I am still working at this, those steps did change the error message
for me.

Trust that helps.

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: REST API Library...finally
September 09, 2010, 12:10:24 am
That sounds like a good example. I use KeePass to generate a key for the user I want to have access via the REST interface, and then use phpmyadmin or MySQL Workbench to set the api_key field in the civicrm_contact table for the specific contact.
Erik
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • REST API Library...finally

This forum was archived on 2017-11-26.