Frage

I'm trying get url contents with file_get_contents(), its works in my localhost server, but in shared host server, the function returns a empty string, without errors. My code follows:

$uri = 'http://my_url.com:81/datasnap/rest/TServerMethods/getLoginCliente/galf/123/';
$result = file_get_contents($uri);
var_dump($result);

and the result is:

string(0) ""

instead of:

{result: [4532,1]}

I'm test change the url for google.com, and works perfectly.

Anyone know why this happens?

War es hilfreich?

Lösung 2

the problem is the firewall host. The firewall is block the port 81.

Andere Tipps

Check if fopen url wrappers are enabled :

var_export(ini_get('allow_url_fopen'));

I suppose it is just disabled as potentially insecure operation.

Add this at the top of your php file

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

And then look for any errors that it gives you. the shared host might have disabled that particular function and in order to have it work you'll have to ask them to enable it.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top