X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fclass.api.php;h=88d9b2116596c52bb40f898c97552faea70bdf26;hb=895ef8f35ddc320a6b9dc486b9eb9d41cdf7d61c;hp=177da3eaff8cbbbf8dccc2e1ee453df6d1699bc4;hpb=638c59ed3d7f7fda62fa581d271c475c473043ce;p=civicrm-core.git diff --git a/api/class.api.php b/api/class.api.php index 177da3eaff..88d9b21165 100644 --- a/api/class.api.php +++ b/api/class.api.php @@ -97,7 +97,6 @@ class civicrm_api3 { else { $this->uri .= '/sites/all/modules/civicrm/extern/rest.php'; } - $this->uri .= '?json=1'; if (isset($config['key'])) { $this->key = $config['key']; } @@ -113,7 +112,9 @@ class civicrm_api3 { return; } if (isset($config) && isset($config['conf_path'])) { - define('CIVICRM_SETTINGS_PATH', $config['conf_path'] . '/civicrm.settings.php'); + if (!defined('CIVICRM_SETTINGS_PATH')) { + define('CIVICRM_SETTINGS_PATH', $config['conf_path'] . '/civicrm.settings.php'); + } require_once CIVICRM_SETTINGS_PATH; require_once 'CRM/Core/ClassLoader.php'; require_once 'api/api.php'; @@ -154,17 +155,6 @@ class civicrm_api3 { } } - /** - * As of PHP 5.3.0. - * - * @param $name - * @param $arguments - */ - public static function __callStatic($name, $arguments) { - // Should we implement it ? - echo "Calling static method '$name' " . implode(', ', $arguments) . "\n"; - } - /** * Call via rest. * @@ -174,16 +164,20 @@ class civicrm_api3 { * * @return \stdClass */ - public function remoteCall($entity, $action, $params = array()) { - $fields = "key={$this->key}&api_key={$this->api_key}"; - $query = $this->uri . "&entity=$entity&action=$action"; - $fields .= '&' . http_build_query($params); + private function remoteCall($entity, $action, $params = array()) { + $query = $this->uri . "?entity=$entity&action=$action"; + $fields = http_build_query(array( + 'key' => $this->key, + 'api_key' => $this->api_key, + 'json' => json_encode($params), + )); + if (function_exists('curl_init')) { // To facilitate debugging without leaking info, entity & action // are GET, other data is POST. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $query); - curl_setopt($ch, CURLOPT_POST, count($params) + 2); + curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); @@ -223,7 +217,7 @@ class civicrm_api3 { * * @return bool */ - public function call($entity, $action = 'Get', $params = array()) { + private function call($entity, $action = 'Get', $params = array()) { if (is_int($params)) { $params = array('id' => $params); }