如何解決php警告:file_get_contents?如何解決php警告:file_get_contents?無法打開流:HTTP請求失敗
Warning: file_get_contents(http://192.168.1.254:9999/api/p/internal/ucenter/login?loginName=test102&password=111111) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /Applications/XAMPP/xamppfiles/htdocs/PHP_test/index.php on line 49
這是關係到$文件中的代碼:
<?php
$loginNames="test102";
$passwords="111111";
$apiUrl = "http://192.168.1.254:9999/api/p/internal/ucenter/login?loginName=".$loginNames."&password=".$passwords;
$callback = file_get_contents($apiUrl);
print_r($callback);
//echo $callback;
?>
您是否像'$ callback = @file_get_contents($ apiUrl); if($ callback!== false)print_r($ callback);'? – inhan
如果您在瀏覽器中轉到該網址,會發生什麼情況?你是否重定向?嘗試使用CURL並查看標題返回的內容。 – shapeshifter
http://stackoverflow.com/questions/12489499/uploading-remote-url-to-server/12489662#12489662爲相似的CURL代碼。 – shapeshifter