2017-02-16 158 views
-1

我正在使用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://使用它?

+2

嘗試增加'HTTP://'在IP地址 – Jerodev

+0

不前不工作,它掛在:5000添加 – user2519424

+1

使用curl而不是file_get_contents <=它使用端口80 – Fky

回答