문제

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?

도움이 되었습니까?

해결책 2

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top