/** * get json-api service map * * @return string */ public static function getServiceMap() { $server = new Zend_Json_Server(); $server->setClass('Setup_Frontend_Json', 'Setup'); $server->setClass('Tinebase_Frontend_Json', 'Tinebase'); $server->setTarget('setup.php')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); $smd = $server->getServiceMap(); $smdArray = $smd->toArray(); unset($smdArray['methods']); return $smdArray; }
public function json() { $vo_server = new Zend_Json_Server(); $vo_server->setClass('ItemInfoService', null, null, $this->request); if ('GET' == $_SERVER['REQUEST_METHOD']) { $vo_server->setTarget(__CA_URL_ROOT__ . '/service.php/iteminfo/ItemInfo/json')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); $this->view->setVar("show_smd", true); } $this->view->setVar("json_server", $vo_server); $this->render("iteminfo_json.php"); }
/** * JSON SERVER */ public function jsonAction() { $server = new Zend_Json_Server(); $server->setClass('My_Application_Model_Data'); if ('GET' == $_SERVER['REQUEST_METHOD']) { $server->setTarget($this->_url)->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); $smd = $server->getServiceMap(); header('Content-Type: application/json'); echo $smd; return; } echo $server->handle(); }
public function jsonAction() { $this->_helper->viewRenderer->setNoRender(); $server = new Zend_Json_Server(); $server->setClass('Application_Model_Data', 'cf'); if ('GET' == $_SERVER['REQUEST_METHOD']) { $server->setTarget('http://localhost/xmlrpc-test/public/server/json')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); $smd = $server->getServiceMap(); header('Content-Type: application/json'); echo $smd; return; } echo $server->handle(); }
/** * JSON-RPC controller * * @return void */ public function indexAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $server = new Zend_Json_Server(); $server->setClass('WorklogService'); if ('GET' == $_SERVER['REQUEST_METHOD']) { $server->setTarget('/rpc/index')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2)->setDojoCompatible(true); $smd = $server->getServiceMap(); header('Content-Type: application/json'); echo $smd; return; } // Handle the request: $server->handle(); }
/** * JSON CLIENT */ public function jsonAction() { $server = new Zend_Json_Server(); $server->setClass('My_Application_Model_Data'); if ('GET' == $_SERVER['REQUEST_METHOD']) { $server->setTarget($this->_url)->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); $smd = $server->getServiceMap(); if (isset($_GET['method'])) { //On recupere les methodes depuis le service map $arrSmd = Zend_Json::decode($smd); //Construction du tableau contenant les liens des methodes $links = '<h2>' . 'Liste des methodes JSON' . '</h2>' . '<table>' . '<tr>'; foreach ($arrSmd["services"] as $serv => $value) { $links .= '<td width="100px" align="center">' . '<a href="' . $this->_url . '?method=' . $serv . '">' . $serv . '</a>' . '</td>'; } $links .= '</tr>' . '</table>'; //Envoi du tableau a la vue $this->view->links = $links; //On recupere la methode appelee $method = $_GET['method']; $nbParam = 0; //Nombre de parametre de la methode //On cree un formulaire contenant les parametres $formtxt = '<form name="' . $method . '" method="post">' . '<table>'; foreach ($smd->getService($method)->getParams() as $param) { $formtxt .= '<tr>' . '<td>' . $param['name'] . ' (' . $param['type'] . ') :</td>' . '<td><input type=text name="' . $param['name'] . '"></td>' . '<tr>'; $nbParam++; } $formtxt .= '<tr>' . '<td></td>' . '<td><input type=submit value=Envoyer></td>' . '</tr>' . '</table>' . '</form>'; //On envoi le formulaire a la vue json client $this->view->form = $formtxt; //On envoi le nom de la methode traitee a la vue $this->view->method = $method; //On envoi le nombre de parametres du formulaire a la vue $this->view->nbParam = $nbParam; } else { $this->_helper->viewRenderer->setNoRender(true); header('Content-Type: application/json'); echo $smd; return; } } else { $this->_helper->viewRenderer->setNoRender(); echo $server->handle(); } }
public function indexAction() { // Instantiate server, etc. $server = new Zend_Json_Server(); Zend_Registry::set("fileserver_helper", $this->_fileHelper); $server->setClass('Admin_Model_FileServer'); if ('GET' == $_SERVER['REQUEST_METHOD']) { // Indicate the URL endpoint, and the JSON-RPC version used: $server->setTarget('/file-server/')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); // Grab the SMD $smd = $server->getServiceMap(); // Return the SMD to the client header('Content-Type: application/json'); echo $smd; die; } $server->handle(); die; }
/** * Bootstrap the whole app for now. * This should be adjusted in the future for performance gains. */ $application->bootstrap(); /** * Force the cache manager because for some reason it ends up empty without * setting the manager manually */ $cache = Zend_Controller_Action_HelperBroker::getStaticHelper('Cache'); $cache->setManager($application->getBootstrap()->getResource('cachemanager')); switch ($_GET['format']) { case 'json': $server = new Zend_Json_Server(); // Indicate the URL endpoint, and the JSON-RPC version used: $server->setTarget('/api/jsonrpc/')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); $contentTypeHeader = 'Content-Type: text/json'; break; case 'xml': $server = new Zend_XmlRpc_Server(); Zend_XmlRpc_Server_Fault::attachFaultException('FFR_Exception'); Zend_XmlRpc_Server_Fault::attachFaultException('Zend_Exception'); $contentTypeHeader = 'Content-Type: text/xml'; break; } $apiList = Zym_Message_Dispatcher::get()->post('buildApi')->getResult('buildApi'); foreach ($apiList as $key => $services) { foreach ($services as $service => $class) { $server->setClass($class, $service); } }
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../')); set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/libraries/')))); require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); /** * ================================================================== * Prepare environment and execute JSON calls * ================================================================== */ require APPLICATION_PATH . '/includes/classes/remote.class.php'; header('Access-Control-Allow-Origin: *'); $server = new Zend_Json_Server(); $server->setClass('Kimai_Remote_Api'); if ('GET' == $_SERVER['REQUEST_METHOD']) { // Indicate the URL endpoint, and the JSON-RPC version used: $server->setTarget('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); // Grab the SMD $smd = $server->getServiceMap(); // Return the SMD to the client header('Content-Type: application/json'); echo $smd; return; } /** * http request will * - parse php://input * - json_decode it * - auto setOptions * therefore request should be a string e.g. {jsonrpc : '2.0', method: '<actionString>', params : [param1, param2], id : '<anyId>' } */ $request = new Zend_Json_Server_Request_Http();
<?php require_once dirname(__FILE__) . '/bootstrap.php'; $plugin = Zend_Registry::get('init'); $request = $plugin->getRequest(); $plugin->initDb(); $loader = new My_Controller_Helper_ResourceLoader(); $loader->initModule('spindle'); $paste = $loader->getService('Paste'); $server = new Zend_Json_Server(); $server->setClass($paste); if ($request->isGet()) { $server->setTarget($request->getBaseUrl() . '/jsonrpc')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); // Grab the SMD $smd = $server->getServiceMap(); // Cache the SMD if ('production' == APPLICATION_ENV && is_writeable(dirname(__FILE__))) { file_put_contents(dirname(__FILE__) . '/content/jsonrpc.smd', $smd); } // Return the SMD to the client header('Content-Type: application/json'); echo $smd; return; } $server->handle();
/** * return service map * * @return Zend_Json_Server_Smd */ public static function getServiceMap() { $server = new Zend_Json_Server(); $server->setClass('Tinebase_Frontend_Json', 'Tinebase'); $server->setClass('Tinebase_Frontend_Json_UserRegistration', 'Tinebase_UserRegistration'); if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) { $server->setClass('Tinebase_Frontend_Json_Container', 'Tinebase_Container'); $server->setClass('Tinebase_Frontend_Json_PersistentFilter', 'Tinebase_PersistentFilter'); $userApplications = Tinebase_Core::getUser()->getApplications(TRUE); foreach ($userApplications as $application) { $jsonAppName = $application->name . '_Frontend_Json'; $server->setClass($jsonAppName, $application->name); } } $server->setTarget('index.php')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); $smd = $server->getServiceMap(); return $smd; }