File_get_contents works on the local, but not on the server

Possible duplicate:
Error file_get_contents ()

Working with a script that connects to the Instagram API to retrieve photos from a specific tag. It works fine on local, but on the server I get errors.

Warning: file_get_contents (): https: // the shell is disabled in the server configuration allow_url_fopen = 0 in / storage / content / 91/103391 / instaboll.nu / public_html / instagram.php on line 19.

Here is line 19:
$ contents = file_get_contents (" https://api.instagram.com/v1/tags/ $ tag / media / recent? client_id = $ client_id");

Any ideas?

Look for this and find a few posts that recommend curl but don't have a clue how to do this.

+6
source share
4 answers

I solved this with this code.

<?php $url = "http://www.example.org/"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $contents = curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); echo "\n<br />"; $contents = ''; } else { curl_close($ch); } if (!is_string($contents) || !strlen($contents)) { echo "Failed to get contents."; $contents = ''; } echo $contents; ?> 
+15
source

The solution is in the error message: set allow_url_fopen to 1 in your ini (use the php.ini , use ini_set in php code or talk to your host).

+4
source

You will need to enable allow_url_fopen from php.ini on your host or talk with hosting providers.

This option allows fopen wrappers that support URLs that allow access to the URL object as files.

+2
source

The server administrator has disabled this feature. You need to ask them to turn it on.

+1
source

Source: https://habr.com/ru/post/917808/


All Articles