Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP cURL authentication

  • 21-08-2008 12:01AM
    #1
    Moderators, Education Moderators, Home & Garden Moderators Posts: 8,314 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, Registered Users 2 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,314 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