ALL NOW SORTED THANKS KIRKMCD & WAYFARER Hi Guys, Looking for an answer to this isse that's had me going around in circles for 2 days and now I'm at a brick wall. There are number of resources that purport to have the solution but they all look like they copied the same script so i am now not convinced it is correct.
RESOLVED-Accessing site via a proxy server with PHP file_get_contents
23
ALL NOW SORTED THANKS KIRKMCD & WAYFARER
Hi Guys,
Looking for an answer to this isse that's had me going around in circles for 2 days and now I'm at a brick wall. There are number of resources that purport to have the solution but they all look like they copied the same script so i am now not convinced it is correct.
Hereis the short test script I have used to test this but I get the following error.
Warning: file_get_contents(The AA: Breakdown Cover, Car Insurance, Home Insurance, Loans, Motoring Advice, Travel and Maps) [function.file-get-contents]: failed to open stream: Connection timed out in /home5/XXXXXXXX/public_html/mkm/tools/test.php on line 11
The script is:
_____________
<?php
function file_get_contents_proxy($url,$proxy){
// Create context stream
$context_array = array('http'=>array('proxy'=>$proxy,'request_fullu ri'=>true));
$context = stream_context_create($context_array);
// Use context stream with file_get_contents
$data = file_get_contents($url,false,$context);
// Return data via proxy
return $data;
}
$url = "http://www.theaa.com";
$proxy = "tcp://132.254.101.52:3128";
file_get_contents_proxy($url,$proxy);
Echo $data
?>
________
$url is an arbitary wesite
$proxy is a randomly chosen public proxy that I have tested both with an online checker and by adding it to my browser config.
If I just use the file_get_contents I can access the file directly but I cannot access it via the proxy.
Anyone familiar with accessing sites/site files via a proxy server?
Really appreciate your help
Will definitely find some kind of "reward" for anyone who gives me the solution.
Or tell me how much
Thanks
Tony
Hi Guys,
Looking for an answer to this isse that's had me going around in circles for 2 days and now I'm at a brick wall. There are number of resources that purport to have the solution but they all look like they copied the same script so i am now not convinced it is correct.
Hereis the short test script I have used to test this but I get the following error.
Warning: file_get_contents(The AA: Breakdown Cover, Car Insurance, Home Insurance, Loans, Motoring Advice, Travel and Maps) [function.file-get-contents]: failed to open stream: Connection timed out in /home5/XXXXXXXX/public_html/mkm/tools/test.php on line 11
The script is:
_____________
<?php
function file_get_contents_proxy($url,$proxy){
// Create context stream
$context_array = array('http'=>array('proxy'=>$proxy,'request_fullu ri'=>true));
$context = stream_context_create($context_array);
// Use context stream with file_get_contents
$data = file_get_contents($url,false,$context);
// Return data via proxy
return $data;
}
$url = "http://www.theaa.com";
$proxy = "tcp://132.254.101.52:3128";
file_get_contents_proxy($url,$proxy);
Echo $data
?>
________
$url is an arbitary wesite
$proxy is a randomly chosen public proxy that I have tested both with an online checker and by adding it to my browser config.
If I just use the file_get_contents I can access the file directly but I cannot access it via the proxy.
Anyone familiar with accessing sites/site files via a proxy server?
Really appreciate your help
Will definitely find some kind of "reward" for anyone who gives me the solution.
Or tell me how much
Thanks
Tony
- KirkMcD
- [1] reply
- Tony Marriott
- [1] reply
- wayfarer
- [1] reply
- Tony Marriott
- wayfarer
- [1] reply
- Tony Marriott
- [1] reply
- shaileshtr
Next Topics on Trending Feed
-
23