How to use CURL to send the request via an URL
时间:2007-10-25 来源:heavenflying
I want to send a request to the servlet in some server with php and deal with the business logic in the servlet. How to implement this interface? Follow me step by step, and enjoy the powerful of the php language.
$output = array(); //define an array to receive the response from the remote server
$request_url = getRemoteServerURL(); //the server url you want to communicate with
$request = urlencode($_POST["formParam"]); // parameters you want to send to the server
$exec_str = "curl '".$ request_url."?request_desc=".$request."'"; //curl and its arguments
//execute the above command, $ret is used to receive the return the value from the command curl.
exec( $exec_str, $output, $ret);
You can continue to deal with the business according to the variables $output and $ret.
You can receive the request parameter from the servlet in the remote server with the following codes.
String SomeParameter =new String(URLDecoder.decode(request.getParameter(“SomeParameterKey”)).getBytes("ISO-8859-1"), "GBK");
OK, that will work well. In a word, CURL is a library, which allows you to connect and communicate with many different types of servers through various protocols.
$output = array(); //define an array to receive the response from the remote server
$request_url = getRemoteServerURL(); //the server url you want to communicate with
$request = urlencode($_POST["formParam"]); // parameters you want to send to the server
$exec_str = "curl '".$ request_url."?request_desc=".$request."'"; //curl and its arguments
//execute the above command, $ret is used to receive the return the value from the command curl.
exec( $exec_str, $output, $ret);
You can continue to deal with the business according to the variables $output and $ret.
You can receive the request parameter from the servlet in the remote server with the following codes.
String SomeParameter =new String(URLDecoder.decode(request.getParameter(“SomeParameterKey”)).getBytes("ISO-8859-1"), "GBK");
OK, that will work well. In a word, CURL is a library, which allows you to connect and communicate with many different types of servers through various protocols.
相关阅读 更多 +
排行榜 更多 +