文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>How to use CURL to send the request via an URL

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.



相关阅读 更多 +
排行榜 更多 +
泡龙大闯关安卓版

泡龙大闯关安卓版

冒险解谜 下载
割草派对安卓版

割草派对安卓版

飞行射击 下载
堡垒攻防战安卓版

堡垒攻防战安卓版

飞行射击 下载