cURL gives me "Authorization Required" error

Discussion in 'PHP' started by afimafis, Jan 24, 2012.

  1. #1
    Hi all,

    i am newbie at curl.here is i get error , i tried many methods to beat this error.but same error
    [h=1]Authorization Required.[/h]
    here is my code thanks



    function curl_download($Url){

    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);


    // is cURL installed yet?
    if (!function_exists('curl_init')){
    die('Sorry cURL is not installed!');
    }

    // OK cool - then let's create a new cURL resource handle
    $ch = curl_init();

    // Now set some options (most are optional)

    // Set URL to download
    curl_setopt($ch, CURLOPT_URL, $Url);

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    // Set a referer
    curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");

    // User agent
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

    // Include header in result? (0 = yes, 1 = no)
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // Should cURL return or print out the data? (true = return, false = print)
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Timeout in seconds
    //curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    // Download the given URL, and return output
    $output = curl_exec($ch);

    // Close the cURL resource, and free system resources
    curl_close($ch);

    return $output;

    }

    print curl_download('http://www.google.com');
     
    afimafis, Jan 24, 2012 IP
  2. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #2
    I believe it may be that you or your host may need to simply upgrade libcurl
     
    Anveto, Jan 27, 2012 IP
  3. BigTim3

    BigTim3 Guest

    Messages:
    266
    Likes Received:
    1
    Best Answers:
    2
    Trophy Points:
    0
    #3
    yea ask host ormaybe site needs logind etails?
     
    BigTim3, Jan 28, 2012 IP
  4. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #4
    I doubt google.com needs login details
     
    Anveto, Jan 28, 2012 IP