2

I want to include the exact output of a URL into my webpage exactly as it is

the code i am using is

$html = file_get_html("http://api.zoopla.co.uk/api/v1/area_value_graphs.js?area=" .$postcode. "&output_type=outcode&api_key=6fg3fbrxqhjkn4mkfrxdu2sr");

$data = json_decode($html, true);

$result1 = $data['average_values_graph_url'];
include $result1; 

the error i get is of the type

Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0

i've tried editing the php.ini file to allow_url_include = On and have restarted my machine but i still get the same error. I can't seem to find the other config files as given by phpinfo(); and can't see why what i've changed doesn't work. What have i done wrong?

Lorenzo Belfanti
  • 1,205
  • 3
  • 25
  • 51
EntropicFox
  • 727
  • 5
  • 11
  • use php --ini in terminal to find location of the php.ini file and change directive. you also need allow_url_fopen to be set for this. Use file_get_contents(). Where did you get file_get_html() from ? – Muhammed Mar 03 '16 at 12:49
  • Both allow_url_fopen and allow_url_include are on. The issue I have when I use file_get_contents() and file_get_html() is that I get something like `GIF87aÔ÷ÿÿÿÿôÄ__Äôÿ_ÄôÄîÜ•::•ÜùùÜ•::•Öܰw//w°âùÿDD•ÜîÄùâ°ÿùâ°w/ÿùÜÿÿùâ°w//w` instead of an image like the website of the link would generate, file_get_html() is from simple dom parser. – EntropicFox Mar 03 '16 at 14:43
  • 1
    yes file_get_contents() will produce that strict when you are fetching an image, it will get image code and translate into string... They can't be both on as error says it is not on.. Can you do echo phpinfo() and see there? Some parameters cannot be changed by user with ini_set or similar options, allow_url_fopen is one of them - PHP_INI_SYSTEM type, if you have it disabled serverwide you need to enable there . Are you using Macs buil-in php? if so your .ini should be /etc/php.ini check there. – Muhammed Mar 03 '16 at 14:46
  • I was an idiot, I just had to display it as an image and it worked fine. Building from your post though, (i did edit the file at /etc/php.ini) how can i enable it serverwide, is that the file you just referenced? – EntropicFox Mar 03 '16 at 14:52
  • good )) please accept my answer – Muhammed Mar 03 '16 at 14:56

1 Answers1

0

Use php --ini in terminal to find location of the php.ini file and change directive. you also need allow_url_fopen to be set for this. Use file_get_contents().

Yes file_get_contents() will produce that strict when you are fetching an image, it will get image code and translate into string. In your string it says GIF, it means you are reading an image file.

They can't be both on as error says it is not on. Do echo phpinfo() and see there.

Some parameters cannot be changed by user with ini_set or similar options, allow_url_fopen is one of them - PHP_INI_SYSTEM type, if you have it disabled server-wide you need to enable there .

On Mac's builtin php your .ini should be /etc/php.ini check there.

Muhammed
  • 1,592
  • 1
  • 10
  • 18