Quantcast
Channel: Creating a web service in PHP - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Answer by Jake Sankey for Creating a web service in PHP

$
0
0

I developed a class that is the PHP native SoapServer class' REST equivalent.

You just include the RestServer.php file and then use it as follows.

class Hello{  public static function sayHello($name)  {    return "Hello, " . $name;  }}$rest = new RestServer(Hello);$rest->handle();

Then you can make calls from another language like this:

http://myserver.com/path/to/api?method=sayHello&name=World

(Note that it doesn't matter what order the params are provided in the query string. Also, the param key names as well as the method name are case-insensitive.)

Get it here.


Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>