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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP cURL authentication

  • 20-08-2008 11:01pm
    #1
    Moderators, Education Moderators, Home & Garden Moderators Posts: 8,260 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,260 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