我正在使用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