Translations of this page:

service.php is the file waiting for HTTP-Requests. It interprets the given parameter, loads the co

ist die auf HTTP-Requests wartende Datei. Sie interpretiert die angegeben Parameter, lädt eine corresponding PHP-Class and executes the desired method. Afterwards it returns the methods result (i.e. the return value) as HTTP-Response. This answer can be eighter JSON-Encoded or PHP-serialized. other formats may be added / implemented easily, JSON is default.

Required Files

  • core/stdfuncs.inc.php In this file a lot of common used functions are defined, service.php uses some of them. Its a general library to avoid re-typing similar code again and again.
  • core/api_provider.inc.php This class instantiates and manages the available web-services.
  • services.inc.php In this file the available web-services will be defined. Every service needs a unique name, a file (in which the class is defined), a class name and the parameters passed to the classes constructor.

All path informations are meant as relative to service.php or relative to a php_include_path

See also: Example content of services.php

POST/GET - Parameter

The file service.php interprets GET and/or POST parameters. Following parameters will be interpreted:

  • service which (in services.inc.php defined) service should be called
  • method which method should be called
  • parameter The parameters passed to the method. PHP-serialized or as array.
  • returnFormat, optional how the HTTP-Response should be formatted, js oder php, default is js
    • js ⇒ JSON Notation
    • php ⇒ PHP-serialized

Example (both are identical, but the serialized (second) version is type safe)

.../service.php?service=timer_zeit&method=getTime&parameter[0]=H:i:s
.../service.php?service=timer_zeit&method=getTime&parameter=a:1:{i:0;s:5:"H:i:s"}

To get all methods a service provides the getMethods method can be called. For this method no service name is needed, it is a method provided by the api_provider itself. as parameter give the name of the service whose methods you like to get.

.../service.php?method=getMethods&parameter[0]=timer_zeit
.../service.php?method=getMethods&parameter=a:1:{i:0;s:10:"timer_zeit"}

Calling the API-Provider itself

The API-Providers itself can be called by just leaving away the parameter service. The API-Provider has two Methods, getCharset() and getMethods(serviceName)

  • getCharset() returns the expected char set, depending on your HTTp-Server's configuration. This needs to be defined in the file services.inc.php by setting the variable $CHAR_SET. This needs to be set since I don't know how to figure out what char set the server expects dynamically.
  • getMethods(serviceName) returns an array of all public methods of the given service.
.../service.php?method=getCharset
 
en/dev/service.php.txt · Last modified: 10.12.2007 16:30 by kaegi
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki