[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/webservice/rest/ -> locallib.php (summary)

REST web service implementation classes and methods.

Copyright: 2009 Jerome Mouneyrac
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 255 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

webservice_rest_server:: (7 methods):
  __construct()
  parse_request()
  send_response()
  send_error()
  generate_error()
  send_headers()
  xmlize_result()

webservice_rest_test_client:: (1 method):
  simpletest()


Class: webservice_rest_server  - X-Ref

REST service server implementation.

__construct($authmethod)   X-Ref
Contructor

param: string $authmethod authentication method of the web service (WEBSERVICE_AUTHMETHOD_PERMANENT_TOKEN, ...)
param: string $restformat Format of the return values: 'xml' or 'json'

parse_request()   X-Ref
This method parses the $_POST and $_GET superglobals and looks for
the following information:
1/ user authentication - username+password or token (wsusername, wspassword and wstoken parameters)
2/ function name (wsfunction parameter)
3/ function parameters (all other parameters except those above)
4/ text format parameters
5/ return rest format xml/json


send_response()   X-Ref
Send the result of function call to the WS client
formatted as XML document.


send_error($ex=null)   X-Ref
Send the error information to the WS client
formatted as XML document.
Note: the exception is never passed as null,
it only matches the abstract function declaration.

param: exception $ex the exception that we are sending

generate_error($ex)   X-Ref
Build the error information matching the REST returned value format (JSON or XML)

param: exception $ex the exception we are converting in the server rest format
return: string the error in the requested REST format

send_headers()   X-Ref
Internal implementation - sending of page headers.


xmlize_result($returns, $desc)   X-Ref
Internal implementation - recursive function producing XML markup.

param: mixed $returns the returned values
param: external_description $desc
return: string

Class: webservice_rest_test_client  - X-Ref

REST test client class

simpletest($serverurl, $function, $params)   X-Ref
Execute test client WS request

param: string $serverurl server url (including token parameter or username/password parameters)
param: string $function function name
param: array $params parameters of the called function
return: mixed



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1