setLog(new CRM_Utils_SystemLogger()); $apiServer->setRouter(function ($cxn, $entity, $action, $params) { require_once 'api/v3/utils.php'; // Note: cxnId is authenticated before router is called. $dao = new CRM_Cxn_DAO_Cxn(); $dao->cxn_id = $cxn['cxnId']; if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) { return civicrm_api3_create_error('Failed to lookup connection authorizations.'); } if (!$dao->is_active) { return civicrm_api3_create_error('Connection is inactive'); } // FIXME: apply $dao->perm return civicrm_api($entity, $action, $params); }); $apiServer->handle(file_get_contents('php://input'))->send();