Using a server to connect to proxys with/password?

webdesign

Regular Member
Joined
May 9, 2009
Messages
430
Reaction score
121
I've been doing a lot of research, but can't seem to get it to work..

The best & most recent thing I have read has been this..


Code:
<?php
$proxy = ""; // must be like proxyip[IMG]http://s.dpstatic.com/smilies/tongue.png[/IMG]ort  (00.00.00.00:8080)

function curl_get_contents(){
global $proxy;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT  5.2; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7");
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
$res = curl_exec($ch);
return $res;
curl_close($ch);
}

echo curl_get_contents('http://www.example.com/');  // replace  file_get_contents with curl_get_contents
?>
From this DP thread. I'm not 100% sure if it works or not, as I only have proxy's with passwords to test.


I've seen loads of code examples for this with passwords in my searching, but I can't seem to get any of them to work.

Code:
http://enam.wordpress.com/2006/11/21/how-to-use-socks-proxy/
http://www.higherpass.com/php/Tutorials/Using-Curl-To-Query-Remote-Servers/3/
http://jdev.blogsome.com/2007/01/15/php-proxy-authentication/
http://www.developer.com/java/other/article.php/1551421/Questions-on-HttpURLConnection-and-Proxies.htm
http://www.sitepoint.com/forums/showthread.php?t=644769
http://gaps33.wordpress.com/2009/11/10/fb-freeeezzzeer-versi-php/
Anyone able to help? I'm using this to make it easier to manage my proxys - on my server instead of having to manually change proxy's every-time I want to update a profile in my browser.
 
Last edited:
Code:
<?  
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://www.example.com'); 
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT  5.2; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7");
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); 
curl_setopt($ch, CURLOPT_PROXY, 'fakeproxy.com:1080'); 
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password'); 
$data = curl_exec(); 
curl_close($ch); 
print $data;
 ?>
If the proxy doens't allow tunneling you will get a error.
Then set
Code:
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, [COLOR=Red]1[/COLOR]);
to zero
Code:
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, [COLOR=red]0[/COLOR]);
Also check if you have the latest cUrl installed.
Some don't have proxy included from the get go.


Cheers for the reply - I tried this with and without 0, 1. And got an error.

Did some research on the error (Warning: Wrong parameter count for curl_exec()) and found an answer saying to put $ch between " $data = curl_exec();" that got rid of the error, however it is not returning the URL I requested, it's just giving me a blank page.


Any Idea whats going on? I'm with hostgator/shared - CURL is enabled and they say it's got proxy support.
 
Update: SCRIPT IS NOW WORKING BUT GOT DISABLED.



(5:53:33 AM) Sean Va: My pleasure. Please give me a few moments, Che.
(5:54:30 AM) Che: sure thing!
(5:56:25 AM) Sean Va: Bad news.
(5:56:36 AM) Sean Va: It works. but it's about to be diabled.
(5:56:49 AM) Sean Va: It violates Terms of Service.
(5:57:09 AM) Che: haha your kidding me
(5:57:42 AM) Che: it's just so i can do some testing
(5:57:47 AM) Sean Va: My apologies, Che. You will be unable to run that script on our servers, it's an issue to connecting to that proxy.
(5:57:53 AM) Che: not making it public or anything
(5:58:25 AM) Che: What TOS does it violate?
(5:58:36 AM) Sean Va: It's certainly out of my hands. I involved a higher authority, they're who corrected it and who infomed me that it's a TOS violation. really nothing I can do, Che.
 
Code:
curl_setopt($curl, curlOPT_HTTPproxyTUNNEL, 0);
  curl_setopt($curl, CURLOPT_PROXY, '221.130.13.38:80');
 
(5:53:33 AM) Sean Va: My pleasure. Please give me a few moments, Che.
(5:54:30 AM) Che: sure thing!
(5:56:25 AM) Sean Va: Bad news.
(5:56:36 AM) Sean Va: It works. but it's about to be diabled.
(5:56:49 AM) Sean Va: It violates Terms of Service.
(5:57:09 AM) Che: haha your kidding me
(5:57:42 AM) Che: it's just so i can do some testing
(5:57:47 AM) Sean Va: My apologies, Che. You will be unable to run that script on our servers, it's an issue to connecting to that proxy.
(5:57:53 AM) Che: not making it public or anything
(5:58:25 AM) Che: What TOS does it violate?
(5:58:36 AM) Sean Va: It's certainly out of my hands. I involved a higher authority, they're who corrected it and who infomed me that it's a TOS violation. really nothing I can do, Che.

Wow what hosting company was that? I'd like to avoid them if possible..
 
ok buddy,
1. Use firefox
2. install add on "Foxyproxy"

Code:
https://addons.mozilla.org/en-US/firefox/addon/2464

Appreciate your help, but I'm looking for something more customizable, which is why I want to do it on a server/my pc.
 
I guess these things always better run on localhost rather on a shared hosting account. if you need linux you can run a virtual linux server with vmware. and localhost is always faster than remote. and running scripts, or bots always better on localhost or on virtual server.
 
Yeh made a little script error, oops.:o
So did you get it up and running? With wamp or something?

It's cool, glad I had your help. Yea, after a few hours or tinkering this morning, finally got it working on a local server.
 
Last edited:
Back
Top