If you want to handle Java interface. This is how it behaves in PHP:
<?php
$url = ' The interface URL address for Java provided here ';//We are unified using JSON format
$ch = Curl_init ();
$timeout = 5;
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_connecttimeout, $timeout);
$contents = curl_exec ($ch);
Curl_close ($ch);
$body = Json_decode ($contents, TRUE);
$data = Array ();
if ($body [' code '] = = =
$data = (array) $body [' Data '];
>
The following is a JSON string that has been processed to return to JavaScript. You just need to put the address of the controller in the form of a URL to the docking personnel can be.
<?php Public
function Action_actionname ()
{
header (' Content-type:application/x-javascript ');
For example, the request
header (' access-control-allow-origin:.baidu.com ') that receives only the. baidu.com domain name;
$callback = Isset ($_get[' callback '))? $_get[' callback ']: ' Callback ';
try {
$rows = select * from *******;//Here is a SELECT statement that extracts results from the database
$data = array (
' code ' =>,
' msg '
=> ' success ',
' data ' => $rows,
);
} catch (Exception $e) {
$data = array (
' code ' => 3000004,
' msg ' => ' illegal operation ',
);
}
echo $callback. ' ('. Json_encode ($data). ') ';
Exit;
}
? >