http user:pass digest via php?

Discussion in 'PHP' started by disgust, Sep 9, 2006.

  1. #1
    I tried the following

    include("http://user:pass@site.com");
    Code (markup):
    that failed. was told php only uses http1.0.

    tried curl:

    
    $ch = curl_init("http://user:pass@site.com");
    $fp = fopen("smoo.txt", "w");
    
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    
    curl_exec($ch);
    curl_close($ch);
    fclose($fp);
    Code (markup):
    smoo.txt has the contents:

    <b>Digest authentication failed.</b>
    Code (markup):
    so how CAN this be done?
     
    disgust, Sep 9, 2006 IP
  2. wmburg

    wmburg Active Member

    Messages:
    300
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #2
    
    $url = "http://www.site.com/restricted";
    $fp = fopen("smoo.txt", "w");
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERPWD, "user:pass");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_exec($ch);
    curl_close($ch);
    
    fclose($fp);
    
    PHP:
     
    wmburg, Sep 9, 2006 IP
  3. disgust

    disgust Guest

    Messages:
    2,417
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    0
    #3
    still getting

    <b>Digest authentication failed.</b>
    Code (markup):
    from that
     
    disgust, Sep 9, 2006 IP
  4. wmburg

    wmburg Active Member

    Messages:
    300
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Oops, it's digest auth. I didn't see that earlier, my fault.
     
    wmburg, Sep 9, 2006 IP
  5. disgust

    disgust Guest

    Messages:
    2,417
    Likes Received:
    133
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yep, that was it. found it a bit before you posted :)

    for anyone curious

    was all that was missing.
     
    disgust, Sep 9, 2006 IP