Find jobs - Debt Consolidation - Debt Consolidation - Find jobs - Debt Consolidation

PDA

View Full Version : Connect Via Proxy To URL With PHP


scottmweaver
Feb 11th 2007, 11:05 pm
Hey guys,

I need software that will use a proxy to connect to a URL.

I'm not making a proxy browsing script, nor anything illegal. I just need it for testing purposes.

Anyone know how to do this simply inside of PHP?

Thanks in advance,
Scott

nico_swd
Feb 12th 2007, 1:04 am
You can use cURL.



$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://your-url.com');
curl_setopt($ch, CURLOPT_PROXY, 'your-proxy-server');
curl_setopt($ch, /*other options you need */);


www.php.net/curl

wmtips
Feb 12th 2007, 7:49 am
If you have no curl, you can use file_get_contents + stream_context_create:


<?

$opts = array('http' => array('proxy' => 'tcp://proxyserver:80', 'request_fulluri' => true));
$context = stream_context_create($opts);

$s = file_get_contents('http://www.google.com', false, $context);

echo $s;
?>

scottmweaver
Feb 12th 2007, 9:30 am
Thanks a lot guys. I'll test those out. :D

timelf123
Mar 25th 2007, 7:25 pm
sorry for the revival, but how can I have that script read a list of proxies? i do not want an array, but rather to read a list of proxies from a txt file

scottmweaver
Mar 25th 2007, 10:36 pm
sorry for the revival, but how can I have that script read a list of proxies? i do not want an array, but rather to read a list of proxies from a txt file



<?php

$proxyfile = "proxies.txt";

$fh = fopen($proxyfile, "r");
if($fh)
{
while(!feof($fh))
{
$proxies = fread($fh, filesize($proxies));
}
fclose($fh);
}

print $proxies;
?>



I think that should do it. Didn't test it though.

Let me know. :)

Scott

conmavn
Mar 26th 2007, 2:02 am
You can pass via proxygate.us