1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using a server to connect to proxys with/password?

Discussion in 'PHP & Perl' started by webdesign, Apr 20, 2010.

  1. webdesign

    webdesign Jr. VIP Jr. VIP Premium Member

    Joined:
    May 9, 2009
    Messages:
    415
    Likes Received:
    113
    Occupation:
    unemployed
    Location:
    UK
    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: Apr 20, 2010
  2. webdesign

    webdesign Jr. VIP Jr. VIP Premium Member

    Joined:
    May 9, 2009
    Messages:
    415
    Likes Received:
    113
    Occupation:
    unemployed
    Location:
    UK

    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.
     
  3. webdesign

    webdesign Jr. VIP Jr. VIP Premium Member

    Joined:
    May 9, 2009
    Messages:
    415
    Likes Received:
    113
    Occupation:
    unemployed
    Location:
    UK
    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.
     
  4. balazs700

    balazs700 Registered Member

    Joined:
    Mar 3, 2010
    Messages:
    58
    Likes Received:
    13
    Location:
    exactly there
    Code:
    curl_setopt($curl, curlOPT_HTTPproxyTUNNEL, 0);
      curl_setopt($curl, CURLOPT_PROXY, '221.130.13.38:80');
     
  5. balazs700

    balazs700 Registered Member

    Joined:
    Mar 3, 2010
    Messages:
    58
    Likes Received:
    13
    Location:
    exactly there
    run from localhost and you have control or run on virtual server
     
    • Thanks Thanks x 1
  6. balazs700

    balazs700 Registered Member

    Joined:
    Mar 3, 2010
    Messages:
    58
    Likes Received:
    13
    Location:
    exactly there
    but what do you want to do with this?
     
  7. webdesign

    webdesign Jr. VIP Jr. VIP Premium Member

    Joined:
    May 9, 2009
    Messages:
    415
    Likes Received:
    113
    Occupation:
    unemployed
    Location:
    UK

    Damn, why did I not think of that. Cheers :) I'm using it to manage my proxies.
     
  8. Grizzy

    Grizzy Senior Member

    Joined:
    Nov 11, 2008
    Messages:
    919
    Likes Received:
    999
    Wow what hosting company was that? I'd like to avoid them if possible..
     
  9. webdesign

    webdesign Jr. VIP Jr. VIP Premium Member

    Joined:
    May 9, 2009
    Messages:
    415
    Likes Received:
    113
    Occupation:
    unemployed
    Location:
    UK

    Hostgator, first problem I've had with them in 2years!
     
  10. webdesign

    webdesign Jr. VIP Jr. VIP Premium Member

    Joined:
    May 9, 2009
    Messages:
    415
    Likes Received:
    113
    Occupation:
    unemployed
    Location:
    UK
    Appreciate your help, but I'm looking for something more customizable, which is why I want to do it on a server/my pc.
     
  11. balazs700

    balazs700 Registered Member

    Joined:
    Mar 3, 2010
    Messages:
    58
    Likes Received:
    13
    Location:
    exactly there
    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.
     
  12. webdesign

    webdesign Jr. VIP Jr. VIP Premium Member

    Joined:
    May 9, 2009
    Messages:
    415
    Likes Received:
    113
    Occupation:
    unemployed
    Location:
    UK
    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: Apr 22, 2010