2016-10-16 6 views
0
에 컬없이

을 사용자 정의 사용자 에이전트와 원격 서버에서 파일을 다운로드 할 수있는 방법이 있나요 :내가 이것을 가지고 (그리고 내 로컬 호스트에서 작동) 지금 PHP5

function get_data($url) { 
$ch = curl_init(); 
$timeout = 30; 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
curl_setopt ($ch, CURLOPT_CAINFO, getcwd()."/cacert.pem"); 
$ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.16 (KHTML, like Gecko) \ Chrome/24.0.1304.0 Safari/537.16'; 
curl_setopt($ch, CURLOPT_USERAGENT, $ua); 
$data = curl_exec($ch); 
curl_close($ch); 
return (string)$data; 

}

하지만 내 웹 서버에서 cUrl을 사용할 수 없습니다. PHP에서 cUrl을 사용하지 않을이 코드를 어떻게 다시 작성할 수 있습니까? 사전에

감사

+0

있다 HTTP 순수 "로 작성 클라이언트 https://github.com/hightman/httpclient와 같은 'php' – fvu

답변

관련 문제