A CiviCRM REST client for Ruby, forked from cap10morgan: github.com/cap10morgan/civicrm-client-rest-ruby
-
Rest interface doc: wiki.civicrm.org/confluence/display/CRMDOC40/REST+interface
-
CiviCRM API forum: forum.civicrm.org/index.php/board,41.0.html
-
CiviCRM FLOSS Manual, Working with the API: en.flossmanuals.net/CiviCRM/DevelopAPI/
Using the CiviCRM API from a remote server requires authorization. There are two ways to do this:
-
Call the API’s login function passing your username and password and receive a PHP session ID. On all subsequent calls include PHPSESSID in the query.
civicrm.login({:name => 'my_user_name', :pass => 'my_password'})
(WARNING: at the time of writing, this form of authorization did not work due to a bug in CiviCRM)
OR
-
Include your user’s api_key in all API calls. No need to call the login function. You may have to define an api_key for your user in the civicrm_contacts table.
Both forms of authorization require you to also include the site key in every query.
site_key
-
The site key of your CiviCRM install. How to configure/find your site key: wiki.civicrm.org/confluence/display/CRMDOC40/Command-line+Script+Configuration
civicrm_url
-
The URL to the base of your CiviCRM install, e.g. yoursite.org/sites/all/modules/civicrm
api_key
-
Optional, your user’s api_key. Found in the civicrm_contacts table.
require 'civicrm' civi_config = {:site_key => "34r089efiohsda34093409erf9uerfs", :civicrm_url => "https://www.example.org/path/to/civi/codebase/civicrm", :api_key => "3r0u43r09uewfi40u4098u34f34fo"} civicrm = CiviCRM::RESTClient.new(civi_config) civicrm.contact_get({:email => "contact@email.com"})