2015-02-05 2 views
0

file_get_contents를 사용하려고하면 다음과 같은 오류 메시지가 나타납니다. (URL이 변경됨). 나는 URL을 호출하면PHP : file_get_contents가 스트림을 열지 못했습니다 : HTTP 요청에 실패했습니다! HTTP/1.0 401 Unauthorized

Warning: file_get_contents(http://user:[email protected]/test/test.xml?cmd=show&user=*) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 401 Unauthorized in /srv/www/htdocs/phonebook.php on line 50 

나는 브라우저는 XML 파일에서 볼 수 있습니다. 그 사이에는 공백이 없습니다. 그러나, 나는 그것을 얻지 않는다. 왜 그것이 작동하지 않습니다. PHP 버전은 5.3.17입니다. 나는 cUrl을 사용해야합니까?

구문은 다음과 같습니다

$xml_echo = "http://".$user.":".$pass."@".$ip .$url; 
echo $xml_echo; 
$xml_string = file_get_contents($xml_echo); 
내가 도착하고 설명 하나해야 할 수도 있습니다, 내가 오류가 발생하는 것을 내가 사용하려고

추가 문제 :

$xml = new SimpleXMLElement(utf8_encode($xml_string)); 

나는 또한 사용하려고 시도 : simplexml_load_string

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /srv/www/htdocs/phonebook.php:55 Stack trace: #0 /srv/www/htdocs/phonebook.php(55): SimpleXMLElement->__construct('') #1 {main} thrown in /srv/www/htdocs/get_pbx_phonebook.php on line 55 

답변

0

아, 그것을 게시 후. //

대신

HTTP : 나는

https로 사용하려고 //

지금은했다.

그래서 도움이 필요하지 않습니다.

관련 문제