Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP cURL authentication

Options
  • 21-08-2008 12:01am
    #1
    Moderators, Education Moderators, Home & Garden Moderators Posts: 8,119 Mod ✭✭✭✭


    What would be the code to cURL to a website with a login and store it in $result?

    An example of such a website being http://broadband.iol.ie/cgi-bin/sec/dsl

    This is what i have but it aint logging in, just keep getting a authentication required message :o
    <?
    
        $url="http://broadband.iol.ie/cgi-bin/sec/dsl";
        $ch = curl_init ($url);
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_HEADER, 0); 
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
        curl_setopt(CURLOPT_USERPWD, "[joebloggs]:[password]");    
        curl_setopt($ch, CURLOPT_REFERER, "http://broadband.iol.ie/usage"); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        $result = curl_exec($ch); 
        curl_close($ch); 
        
    
    echo $result;
    ?>
    


Comments

  • Registered Users Posts: 2,793 ✭✭✭oeb


    jmccrohan wrote: »
    What would be the code to cURL to a website with a login and store it in $result?

    An example of such a website being http://broadband.iol.ie/cgi-bin/sec/dsl

    This is what i have but it aint logging in, just keep getting a authentication required message :o
    <?
    
        $url="http://broadband.iol.ie/cgi-bin/sec/dsl";
        $ch = curl_init ($url);
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_HEADER, 0); 
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
        curl_setopt(CURLOPT_USERPWD, "[joebloggs]:[password]");    
        curl_setopt($ch, CURLOPT_REFERER, "http://broadband.iol.ie/usage"); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        $result = curl_exec($ch); 
        curl_close($ch); 
        
    
    echo $result;
    ?>
    


    Have you tried calling the address with joebloggs:password@broadband.iol.ie?


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,119 Mod ✭✭✭✭Jonathan


    oeb wrote: »
    [noparse]Have you tried calling the address with joebloggs:password@broadband.iol.ie?[/noparse]
    You are a genius. Much appreciated. thank you.


Advertisement