getMethod($_REQUEST['job'])->getNumberOfRequiredParameters(); unset($rc); if ($pCount > 0 && (!$_REQUEST['params'] || $_REQUEST['params']=="")) myDie('Params exception'); $params = json_decode(base64_decode($_REQUEST['params'])); if ($pCount>0 && ! is_array($params) && $pCount > sizeof($params)) myDie('Params exception '); //REQUEST data checked, now execute job if (! defined ( 'sugarEntry' )) define ( 'sugarEntry', true ); if (is_array($params) && sizeof($params) > 0) $res = call_user_func_array(array($c,$_REQUEST['job']), $params); else $res = $c->$_REQUEST['job'](); echo json_encode($res); sugar_cleanup(); exit(); //little helper fn function myDie($msg) { echo json_encode(array ($msg)); sugar_cleanup(); exit; }