source: trunk/include/ws_protocols/rest_handler.php @ 1863

Last change on this file since 1863 was 1768, checked in by rvelices, 17 years ago

web services: give vincent the calling partner id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
5// +-----------------------------------------------------------------------+
6// | branch        : BSF (Best So Far)
7// | file          : $Id: rest_handler.php 1768 2007-01-29 20:38:08Z rvelices $
8// | last update   : $Date: 2007-01-29 20:38:08 +0000 (Mon, 29 Jan 2007) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Rev: 1768 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27class PwgRestRequestHandler
28{
29  function handleRequest(&$service)
30  {
31    $params = array();
32
33    $param_array = $service->isPost() ? $_POST : $_GET;
34    foreach ($param_array as $name => $value)
35    {
36      if ($name=='format' or $name=='partner')
37        continue; // ignore - special keys
38      if ($name=='method')
39      {
40        $method = $value;
41      }
42      else
43      {
44        $params[$name]=$value;
45      }
46    }
47
48    if ( empty($method) )
49    {
50      $service->sendResponse(
51          new PwgError(400, 'Missing "method" name')
52        );
53      return;
54    }
55    $resp = $service->invoke($method, $params);
56    $service->sendResponse($resp);
57  }
58}
59
60?>
Note: See TracBrowser for help on using the repository browser.