note: This post is from 2012. It was imported from wordpress for nostalgic reasons.
Some time ago I wanted a standard for all my ajax RPC requests for my PHP projects. After searching the web, I found the JsonRPC2 standard (http://www.jsonrpc.org/spec.html)
What it does
The server version (in PHP) makes your defined classes accessible trough the JsonRPC2 protocol. (See the README.md in the git) Simply define the classes you want access to and you’re ready to go! It’s quite simple to use and perfect to implement in any class-based php project.
This was a hard one. I wanted it to be as simple as it could:
- Define the endpoint (api url) as follows : rpc = new jsonrpc2client(‘http://localhost/api.php’)
After a lot of debugging, I succeeded in my mission. I’m really proud of what I’ve written in the client. It’s simple, easy to use.
The PHP Client
- Every class init of jsonrpc2client can contain only one rpc class
- No problems with async
1. isn’t exactly a problem. It’s quite excellent! It works exacly as simple php classes behave. (again, check the README.md for example). You just define a new jsonrpc2client with 2 parameters: the endpoint (api url), and the class to connect to.
The Python client
This one works exactly as the php client. It uses the
__getattr__ magic python function to call a method of a class.
So, I hope you enjoy the libs I’ve written. If you do, it would be awesome to buy me a beer !.