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

PROXY use with PHP Curl/file_get_contents

Discussion in 'PHP & Perl' started by lanbo, Sep 17, 2011.

  1. lanbo

    lanbo Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 23, 2009
    Messages:
    3,433
    Likes Received:
    595
    Home Page:
  2. xenon2010

    xenon2010 Regular Member

    Joined:
    Apr 27, 2010
    Messages:
    231
    Likes Received:
    48
    Occupation:
    web and desktop apps programmer
    Location:
    prison
    Home Page:
    here:

    PHP:
    $ch curl_init();
    curl_setopt($chCURLOPT_URL'http://www.example.com');
    curl_setopt($chCURLOPT_HEADER1);
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    curl_setopt($chCURLOPT_HTTPPROXYTUNNEL1);
    curl_setopt($chCURLOPT_PROXY'fakeproxy.com:1080');
    curl_setopt($chCURLOPT_PROXYUSERPWD'user:password');
    $data curl_exec();
    curl_close($ch); 


    if you get error "HTTP/1.0 405 Method Not Allowed"
    try to change
    PHP:
    curl_setopt($chCURLOPT_HTTPPROXYTUNNEL0);
    now give me some rep :p
     
  3. ``Yousef

    ``Yousef Power Member

    Joined:
    Oct 16, 2009
    Messages:
    534
    Likes Received:
    286
    Location:
    Cooking up the medicine.
    Home Page:
    I'm not entirely sure (can't remember) but that may be the error returned when allow_url_fopen is set to off in your php.ini. To test this I would just run a php file containing the function phpinfo(); on your server.

    You should definitely use cURL (functionality aside - it proves the faster data retriever with all benchmarks I've seen so far) as per the above poster, but I just thought I'd give some insight as to why your file_get_contents() request may be failing.