库为PHP消费编写PHP Web服务[重复]

Possible Duplicate:
Framework for providing API access to website?

I need to write a service in PHP. The server will be used by android/iphone clients through the url for example like this

http://www.myservice.com/query.php?param1=a&param2=2...
  • The server will return data back
  • The client will push data to server
  • There can be large num of clients simultaneously accessing so the performance is key

I want to use the data format that is easily understood by my android client. In other words, I do not want to reinvent the wheel and create my own format and parsing, instead I would prefer to use any library if it exists. Is there a framework that I can use to abstract the communication mechanism for data get and push ?

Thanks, Ahmed

well, Use mvc framework(yii, ci, ...) and from controller directly print json_encode($object).

It will return json data to browser, and consume it anywhere(compuer, droid, iphone, ... , iron :D). the solution is json. just share object in json format, so anyone can map it into it's preferred obejct

here is something something you may have a look

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 Java 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.

Being the Author of Restler, I would like to suggest that you can try Restler 3 for the following reasons

  • It is specifically made for API creation
  • It handles media type conversion for you and supports many media types including
    • JSON
    • Plist (both XML and Binary)
    • XML
  • Comes with many examples to get started.
  • Your API is automatically documented with Restler API Explorer