How can I execute a PHP script from Java?

后端 未结 6 381
迷失自我
迷失自我 2020-12-16 03:01

I have a php script which is executed over a URL. (e.g. www.something.com/myscript?param=xy)

When this script is executed in a browser it gives a coded result, a neg

6条回答
  •  无人及你
    2020-12-16 03:51

    I faced exactly the same issue today. For me, that thing which worked was URLEncoding the PHP script parameters using java.net.URLEncoder.encode method.

    String sURL = "myURL";
    String sParam="myparameters";
    String sParam=java.net.URLEncoder.encode(sParam,"UTF-8");
    String urlString=sURL + sParam;     
        HttpClient http = new HttpClient();
        try {
            http.getHttpResponse(urlString);
        } catch (AutomationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        http=null;
    

提交回复
热议问题