So essentially a REST service?
Basically, you need a script that sits on the server and waits for something to call it, with or without input, depending on whether you need to send it information for processing or if it simply returns information without filters or whatever something else. Processing the information looks the same as processing the form from the local page, since you will probably send requests to GET or POST using cURL, although you can also do something like file_get_contents (" http://www.server.com/ RESTscript.php? Id = 23 ") when using $ _GET.
When a request arrives, the script passes the information sent and processes it and returns the information, possibly in JSON format with json_encode () / json_decode () or the XML format that the script that called the REST service will have to do everything you need.
So, for a small, quick, dirty, and static example:
//You would use whatever scripting to build the needed array //Also, note that the only output on the script should be what is being returned to the caller $requested = array('id' => 23, 'name' => 'John Smith', 'info' => 'abcdefghijklmnopqrstuvwxyz'); echo json_encode($requested);
and the calling script will do something like this:
$request = json_decode(file_get_contents("http://www.server.com/REST.php?optional=value"));
which would make $ request an array the same as the requested $, or it could make it stdobj, not sure to forget that. In any case, itβs easy to work. This is all that is required, as a simple and useless web service that you can get.
Phoenix
source share