文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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.



相关阅读 更多 +
排行榜 更多 +
小小的身影重叠的内心游戏下载

小小的身影重叠的内心游戏下载

角色扮演 下载
决战狙击战场手游下载

决战狙击战场手游下载

策略塔防 下载
象棋旋风手机版下载

象棋旋风手机版下载

休闲益智 下载