BVB Source Codes

The latest thinkphp v5.2 work order system Show jsonRPCServer.php Source code

Return Download The latest thinkphp v5.2 work order system: download jsonRPCServer.php Source code - Download The latest thinkphp v5.2 work order system Source code - Type:.php
  1. <?php
  2. /*
  3.                                         COPYRIGHT
  4.  
  5. Copyright 2007 Sergio Vaccaro <sergio@inservibile.org>
  6.  
  7. This file is part of JSON-RPC PHP.
  8.  
  9. JSON-RPC PHP is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13.  
  14. JSON-RPC PHP is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with JSON-RPC PHP; if not, write to the Free Software
  21. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  22. */
  23.  
  24. /**
  25.  * This class build a json-RPC Server 1.0
  26.  * http://json-rpc.org/wiki/specification
  27.  *
  28.  * @author sergio <jsonrpcphp@inservibile.org>
  29.  */
  30. class jsonRPCServer {
  31.         /**
  32.          * This function handle a request binding it to a given object
  33.          *
  34.          * @param object $object
  35.          * @return boolean
  36.          */
  37.         public static function handle($object) {
  38.                
  39.                 // checks if a JSON-RCP request has been received
  40.                 if (
  41.                         $_SERVER['REQUEST_METHOD'] != 'POST' ||
  42.                         empty($_SERVER['CONTENT_TYPE']) ||
  43.                         $_SERVER['CONTENT_TYPE'] != 'application/json'
  44.                         ) {
  45.                         // This is not a JSON-RPC request
  46.                         return false;
  47.                 }
  48.                                
  49.                 // reads the input data
  50.                 $request = json_decode(file_get_contents('php://input'),true);
  51.                
  52.                 // executes the task on local object
  53.                 try {
  54.                         if ($result = @call_user_func_array(array($object,$request['method']),$request['params'])) {
  55.                                 $response = array (
  56.                                                                         'id' => $request['id'],
  57.                                                                         'result' => $result,
  58.                                                                         'error' => NULL
  59.                                                                         );
  60.                         } else {
  61.                                 $response = array (
  62.                                                                         'id' => $request['id'],
  63.                                                                         'result' => NULL,
  64.                                                                         'error' => 'unknown method or incorrect parameters'
  65.                                                                         );
  66.                         }
  67.                 } catch (Exception $e) {
  68.                         $response = array (
  69.                                                                 'id' => $request['id'],
  70.                                                                 'result' => NULL,
  71.                                                                 'error' => $e->getMessage()
  72.                                                                 );
  73.                 }
  74.                
  75.                 // output the response
  76.                 if (!empty($request['id'])) { // notifications don't want response
  77.                         header('content-type: text/javascript');
  78.                         echo json_encode($response);
  79.                 }
  80.                
  81.                 // finish
  82.                 return true;
  83.         }
  84. }
  85. ?>
  86.  
downloadjsonRPCServer.php Source code - Download The latest thinkphp v5.2 work order system Source code
Related Source Codes/Software:
V3.3.6 Workerman high-performance PHP Socket (framework) - High performance PHP Socket framework Workerman re... 2017-05-03
The phosphor meeting room reservation system MRBS (loop reservation v16.0) - The phosphor meeting room reservation system MRBS ... 2017-05-03
IDC v5.2.3 agent center - IDC Centre IDC for exploitation is a PHP+MySQL age... 2017-05-03
Zen master v9.0.1 project management software - Zen is the first domestic open source project mana... 2017-05-03
Ray speed v7.03 employee files management system - Employee files project is various, and some conten... 2017-05-03
HITCMS Haitian responsive electronic mechanical v3.0 foreign trade website source code - HITCMS Haitian response electronic machinery trade... 2017-05-03
Ray v7.02 speed survey system - Lightning speed survey system is a. NET+MSSQL deve... 2017-05-03
Cool HITCMS reactive black v3.0 enterprise website source code - HITCMS-Haitian response black enterprises website ... 2017-05-03
WebOA v17.2 network office automation system - WebOA network using b/s structure development of o... 2017-05-03
Pure imitation of han site source code, one a 】 【 c9cms kernel v1.0 - Generic http://www.wufazhuce.com/Han one · Config... 2017-05-04
zone.js - Implements Zones for JavaScript ... 2017-05-11
dragonfly - A Ruby gem for on-the-fly processing - suitable fo... 2017-05-11
oh-my-fish - The Fishshell Framework. 2017-05-11
canvas-lms - The open LMS by Instructure, Inc. 2017-05-11
ledger - Double-entry accounting system with a command-line... 2017-05-11
Python - My Python Examples http://w... 2017-05-11
blade - 2017-05-11
LaZagne - Credentials recovery project 2017-05-10
Pull-to-Refresh.Rentals-iOS - This project aims to provide a simple and customiz... 2017-05-10
spoon - Distributing instrumentation tests to all your And... 2017-05-10

 Back to top