我正在使用file_get_contents
从第二个Web服务器检索信息。我使用下面的代码:使用PHP file_get_contents获取IP地址
$json_url ="http://example.com/thisworks.html";
$json = file_get_contents($json_url);
$links = json_decode($json, TRUE);
但是连接到我的网络服务器我使用的是IP地址与端口,但下面的代码(与IPadress的file_get_contents)不工作:
$json_url ="44.44.44:5000";
$json = file_get_contents($json_url);
$links = json_decode($json, TRUE);
(44.44.44是当然的一例)
UPDATE 1:
我发现了错误:
[function.file-get-contents]: failed to open stream
更新2:
只需简单地添加的是http://不起作用
更新3:
http://44.44.44
作品,但http://44.44.44:5000
不会(和我因为我使用的程序需要使用:5000端口)
有没有办法使用file_get_contents
这种方式?或者只能通过http://或https://使用它?
尝试增加'HTTP://'在IP地址 – Jerodev
不前不工作,它挂在:5000添加 – user2519424
使用curl而不是file_get_contents <=它使用端口80 – Fky