Thinkphp built-in JSONRPC defect analysis, thinkphp built-in jsonrpc_php tutorial

Source: Internet
Author: User

Thinkphp built-in JSONRPC flaw analysis, thinkphp built-in JSONRPC


In this paper, the defects of thinkphp built-in JSONRPC are analyzed in detail. Share to everyone for your reference. The specific analysis is as follows:

Recently in the development of iOS applications, to develop iOS applications, of course, to use the server, with the server must choose the remote call protocol, because before I have been developed with PHP, so choose thinkphp when the framework of the Apache server.

As for the remote call protocol, after thinking, or choose Jsonrpc Bar, relatively simple and convenient, turned over a thinkphp (is 3.2 version) of the manual, found thinkphp or support JSONRPC, this is good ah, do not have to write (of course, their own writing is not any trouble) .

Simply, using thinkphp to do the client, to call the thinkphp server-side interface, useful.

Next is the Android side, casually went to the Internet to find a package (Android-json-rpc.jar), call the interface, eh! Also good, progress is smooth.

Next change iOS, take GitHub to find a OBJC-JSONRPC project, fetch to call interface, not good, very normal, may be I find the project has a problem, so I changed a demiurgic-json-rpc, or not good use, I started on the program produced doubts, Because the web-side and Android-side calls are fine, so I focused on my iOS program, my days, it took me half a day, I just didn't find the problem, I also use the iOS to call the other side of the JSP client interface, no problem ah.

Later, I began to look at the thinkphp built-in JSONRPC module, after constant debugging (various debugging, and delete code, and dbug), found such a line of code:
Copy the code as follows: $result = @call_user_func_array (Array ($object, $request [' method ']), $request [' params '])

Notice that this function does not, Call_user_func_array,array, point in to see the parameter description, sure enough, $request [' params '] must be an array type, not an array of dead and alive, and, more hateful, Thinkphp did not strictly check this parameter, so they do not know how to be wrong.

Know this reason is good to do, the front plus calibration.
Copy the code as follows: if (Is_array ($request [' params ')]) {
$request [' params '] = array_values ($request [' params ']);
} else {
$request [' params '] = Array ($request [' params ']);
}
This solves the problem perfectly.

It is hoped that this article is helpful to the PHP program design based on thinkphp framework.

http://www.bkjia.com/PHPjc/929676.html www.bkjia.com true http://www.bkjia.com/PHPjc/929676.html techarticle thinkphp built-in JSONRPC flaw analysis, thinkphp built-in JSONRPC this paper analyses the defects of thinkphp built-in jsonrpc in detail. Share to everyone for your reference. The specific analysis is as follows: most ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.