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

Need help with Curl And proxy

Discussion in 'PHP & Perl' started by zozor, Oct 16, 2009.

  1. zozor

    zozor Junior Member

    Joined:
    Dec 24, 2008
    Messages:
    113
    Likes Received:
    70
    I tried tens of way I still can't get the proxybonanza proxies to work with Curl.
    Anyone can show me an example of using a proxy with Curl ?
    Any help will be greatly appreciated
     
  2. insider

    insider Regular Member

    Joined:
    Jul 5, 2009
    Messages:
    344
    Likes Received:
    134
    Location:
    Europe
    Well you just have to add this before you call curl_exec.

    curl_setopt($ch, CURLOPT_PROXY, "11.11.11.11:8080″ );
    curl_setopt($ch, CURLOPT_PROXYUSERPWD,"user:pass");

    Do you get an error message or something ?
     
  3. insider

    insider Regular Member

    Joined:
    Jul 5, 2009
    Messages:
    344
    Likes Received:
    134
    Location:
    Europe
    You just have to add this before you call curl_exec.

    Code:
    curl_setopt($ch, CURLOPT_PROXY, ?11.11.11.11:8080″ );
    curl_setopt($ch, CURLOPT_PROXYUSERPWD,?user:pass?);
    Do you get an error message or something ?
     
  4. insider

    insider Regular Member

    Joined:
    Jul 5, 2009
    Messages:
    344
    Likes Received:
    134
    Location:
    Europe
    You just have to add this before you call curl_exec.

    Code:
    curl_setopt($ch, CURLOPT_PROXY, ?11.11.11.11:8080″ );
    curl_setopt($ch, CURLOPT_PROXYUSERPWD,?user:pass?);
    Do you get an error message or something ?
     
  5. insider

    insider Regular Member

    Joined:
    Jul 5, 2009
    Messages:
    344
    Likes Received:
    134
    Location:
    Europe
    You just have to add this before you call curl_exec.

    Code:
    curl_setopt($ch, CURLOPT_PROXY, ?11.11.11.11:8080″ );
    curl_setopt($ch, CURLOPT_PROXYUSERPWD,?user:pass?);
    Do you get an error message or something ?
     
  6. insider

    insider Regular Member

    Joined:
    Jul 5, 2009
    Messages:
    344
    Likes Received:
    134
    Location:
    Europe
    You just have to add this before you call curl_exec.

    Code:
    curl_setopt($ch, CURLOPT_PROXY, ?11.11.11.11:8080″ );
    curl_setopt($ch, CURLOPT_PROXYUSERPWD,?user:pass?);
    Do you get an error message or something ?
     
  7. zozor

    zozor Junior Member

    Joined:
    Dec 24, 2008
    Messages:
    113
    Likes Received:
    70
    I did that but It does nothing. No error messages nothing
    Heres my code
    PHP:
    $ch=curl_init("www.google.com");
    curl_setopt($chCURLOPT_HTTPPROXYTUNNELTRUE);
      
    curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)');
    curl_setopt($chCURLOPT_PROXY"74.55.61.131:61336");
    curl_setopt($chCURLOPT_PROXYUSERPWD,"user:pass");
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    $data=curl_exec($ch);
    print_r($data);
    Can you share a working code (I can pay if needed )
     
    Last edited: Oct 16, 2009
  8. Nitros

    Nitros Power Member

    Joined:
    Jan 30, 2009
    Messages:
    573
    Likes Received:
    295
    try this:

    Code:
    <?php
    $url = 'http://somesite.com';
    $ch = curl_init();
    curl_setopt($ch, curlOPT_URL,$url);
    curl_setopt($ch, curlOPT_HTTPproxyTUNNEL, 0);
    curl_setopt($ch, curlOPT_proxy, '74.55.61.131:61336');
    curl_setopt($ch, curlOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, curlOPT_RETURNTRANSFER, 0);
    curl_setopt($ch, curlOPT_CUSTOMREQUEST,'GET');
    curl_setopt ($ch, curlOPT_HEADER, 1);
    curl_exec ($ch);
    $curl_info = curl_getinfo($ch);
    curl_close($ch);
    echo '<br />';
    print_r($curl_info);
    ?> 
     
  9. zozor

    zozor Junior Member

    Joined:
    Dec 24, 2008
    Messages:
    113
    Likes Received:
    70
    It still doesn't work I can't get get why. I always get a blank output
     
  10. insider

    insider Regular Member

    Joined:
    Jul 5, 2009
    Messages:
    344
    Likes Received:
    134
    Location:
    Europe
    Did you double check that curl is enlabed on your host ?
    You can check that with phpinfo();
    And does your host allow outgoing conections ?
     
  11. embersion

    embersion BANNED BANNED

    Joined:
    Jun 13, 2009
    Messages:
    430
    Likes Received:
    15
    still you looking for ??
     
  12. mrankin

    mrankin Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 17, 2008
    Messages:
    1,219
    Likes Received:
    572
    Location:
    Australia
    Home Page:
    Try setting the below so you actually get the page back

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);