www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to do curl Authentication?

  1. #1
    Join Date
    Feb 2011
    Posts
    7

    How to do curl Authentication?

    Hi, iam working on a curl based authentication and iam sending a curl request to one of my pages, like this:

    PHP Code:
    <?php
    $ch 
    curl_init("http://localhost/test.php");
            
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    curl_setopt($curlCURLOPT_HTTPAUTHCURLAUTH_BASIC);
    curl_setopt($curlCURLOPT_USERPWD'myuser:mypwd'); 
    // sending username and pwd.                   
    curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);                          
    curl_setopt($curlCURLOPT_FOLLOWLOCATIONtrue);                           
    curl_setopt($curlCURLOPT_USERAGENT'Sample Code');
    curl_setopt($curlCURLINFO_HEADER_OUTtrue);

    $output curl_exec($ch);
    print_r(curl_getinfo($ch));      
    curl_close($ch);
    echo 
    '<br><br>';
    echo 
    $output;
    ?>
    But in my test.php page, iam not able to get the username and password values, in $_SERVER array. What could be the problem?

  2. #2
    Join Date
    Feb 2011
    Posts
    7

    Smile Got it

    Finally i realised that my php is installed as CGI. So it wont work directly. Had referred to this link and now i got the username and password values in $_SERVER array.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles