ThinkPHP built-in jsonRPC defect analysis, thinkphp built-in jsonrpc. The built-in jsonRPC defect analysis of ThinkPHP and the built-in jsonrpc of thinkphp are described in detail in this article. Share it with you for your reference. The specific analysis is as follows: the most ThinkPHP built-in jsonRPC defect analysis, thinkphp built-in jsonrpc
This article analyzes in detail the defects of built-in jsonRPC in ThinkPHP. Share it with you for your reference. The specific analysis is as follows:
Recently I have been developing ios applications. to develop ios applications and use servers, the remote call protocol must be used for servers, because I have been using php for a long time, therefore, thinkphp is used as the apache server of the framework.
As for the remote call protocol, I think it's easy to use jsonRPC. I flipped through the thinkphp (version 3.2) manual and found that thinkphp still supports jsonRPC, you don't have to write it yourself (of course writing it yourself is not a hassle ).
In simple terms, thinkphp is used as the client to call the thinkphp server interface, which is easy to use.
Next is android end, casually go online to find a package (android-json-rpc.jar), call the interface, Ah! It is also easy to use, and the progress is very smooth.
Next I changed to ios. I found an objc-JSONRpc project on github to call the interface. it's not easy to use. it's normal. maybe it's because I have a problem with the project I'm looking, so I changed a Demiurgic-JSON-RPC, or not easy to use, I began to have doubts about the program, because the web side and android side call is no problem, so I focused on my ios program. it took me half a day to find out what went wrong, I also used the ios client to call the jsp client interfaces provided by others.
Later, I started to look at the built-in jsonRPC module of thinkphp. after continuous debugging (various debugging, code deletion, and Dbug), I found such a line of code:
The code is as follows:
$ Result = @ call_user_func_array (array ($ object, $ request ['method']), $ request ['params'])
Didn't notice this function, call_user_func_array, array, click it to see the parameter description. sure enough, $ request ['params '] must be of the array type, not an array that is hard to recognize or hate, thinkphp does not strictly verify this parameter, so it does not know how to make a mistake.
It is easy to understand the cause, and check the above.
The code is as follows:
If (is_array ($ request ['params']) {
$ Request ['params'] = array_values ($ request ['params']);
} Else {
$ Request ['params'] = array ($ request ['params']);
}
In this way, the problem is solved perfectly.
I hope this article will help you design PHP programs based on the ThinkPHP framework.
This article analyzes in detail the defects of built-in jsonRPC in ThinkPHP. Share it with you for your reference. The specific analysis is as follows...