Forum Stats

  • 3,817,474 Users
  • 2,259,340 Discussions
  • 7,893,791 Comments

Discussions

Read PHP content

Aykut
Aykut Member Posts: 53
edited Aug 1, 2017 8:27AM in Java Programming

Hi,


How can I access the content of a PHP URL?

I don't want to get the php code .

I want to get the html content of the "executed" php website.

Following Code works fine with html website, and some php webpages, but not all php webpages

// source: http://...public void readWebsite(String source) {URL oracle;try {oracle = new URL(source);        URLConnection yc = oracle.openConnection();        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));                String inputLine;        while ((inputLine = in.readLine()) != null)             System.out.println(inputLine);                in.close();        } catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}

Error Message I get is:

java.io.IOException: Server returned HTTP response code: 403 for URL:

Thanks,

Aykut

morgalr

Answers

  • handat
    handat Member Posts: 4,688 Gold Crown
    edited Aug 1, 2017 8:27AM

    You are getting a 403 response code which means forbidden. You don't have access. Nothing to do with your java code, it just reads whatever it gets and it is not getting anything since you don't have access to the URL you are trying to connect to. You probably need to authenticate to the URL first. Whether the code used to generate the content on the URL you are trying to connect to is PHP is irrelevant.

    morgalr
This discussion has been closed.