View Single Post
Old 09-25-2007, 01:42 AM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I don't believe there's any way to add proxy support to the native file_get_contents(), but I've wrote you a function below, file_get_contents_proxy() that adds proxy support via the cURL library which will need to be enabled.

Note: Really tired so it may not even work :( ! Someone else will be able to help you from this if not.

PHP Code:
function file_get_contents_proxy($szURL$szProxy$iProxyPort 8080)
{
    
$pCurl curl_init($szURL);
    
    
curl_setopt(CURLOPT_PROXY$szProxy);
    
curl_setopt(CURLOPT_PROXYPORT$iProxyPort);
    
    
curl_setopt(CURLOPT_FOLLOWLOCATIONtrue);
    
curl_setopt(CURLOPT_RETURNTRANSFERtrue);
    
    return 
curl_exec($pCurl);
}

$szURL 'http://www.google.com/';
$szProxy 'myProxy.com';

file_get_contents_proxy($szURL$szProxy); 
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote