2013-03-29 2 views
0

인터넷을 검색 할 때 인증 기능이있는 프록시 서버를 사용하는 대학 네트워크에 있습니다.우분투에서 PHP 용 프록시를 설정하는 방법은 무엇입니까?

내가 html_get_contents를 사용하여 웹 사이트에서 데이터를 가져 오기 위해 노력하고 있지만, 터미널에서 스크립트를 실행하고 나에게 오류를 제공합니다

PHP Warning: file_get_contents(http://www.google.com/): failed to open stream: Network is unreachable in /var/www/api/get_contents.php on line 2

나는 다음과 같이이 어떻게 사용하고 코드 :

<?php 
    $contents = file_get_contents("http://www.google.com/"); 
    echo $contents; 
?> 

나는이 설정합니까 어디, 내용을 얻을 수 php에 대한 프록시를 설정해야 할 것 같다?

답변

1

curl을 사용하십시오. http://www.php.net/manual/en/function.curl-setopt.php 설정 옵션에서

"CURLOPT_PROXYAUTH", "CURLOPT_PROXYPORT", "CURLOPT_PROXYTYPE"

+0

야, 덕분에 많은 @AlexeyKa, 나는 지금'file_get_contents'을 사용하고 싶었 여기 질문에서 대답을 얻었다 : HTTP : //stackoverflow.com/questions/5139459/file-get-contents-behind-a-isa-proxy-under-apache? rq = 1 – jobin

관련 문제