Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4621984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:46:47+00:00 2026-05-22T02:46:47+00:00

I try to get a page with curl from an IIS-Server which demands user

  • 0

I try to get a page with curl from an IIS-Server which demands user authentication.

The curl_exec returns nothing, CURLOPT_RETURNTRANSFER is true. If CURLOPT_RETURNTRANSFER is false the curl_exec returns true.

What’s the problem? The page is neither after successfull nor after unsuccessful authentication empty.

$username = $_POST["acc"];
$password = $_POST["pw"];
$url = "https://secure.website.com/";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
$page = curl_exec($ch);
echo "Error: " . print_r(curl_getinfo($ch)) . "<br>";
curl_close($ch);

echo "<br>Page:<br>" . $page  . "<br>---------------------------<br>";

The script output looks like this:

Array ( [url] => https://secure.website.com/
        [content_type] => text/html
        [http_code] => 302
        [header_size] => 435
        [request_size] => 137
        [filetime] => -1
        [ssl_verify_result] => 20
        [redirect_count] => 0
        [total_time] => 0.187
        [namelookup_time] => 0
        [connect_time] => 0
        [pretransfer_time] => 0.046
        [size_upload] => 0
        [size_download] => 0
        [speed_download] => 0
        [speed_upload] => 0
        [download_content_length] => 0
        [upload_content_length] => 0
        [starttransfer_time] => 0.187
        [redirect_time] => 0
        [certinfo] => Array ( ) )
        Error: 1

Page:

---------------------------

curl_error outputs no error. The “Error: 1” at the end of the curl_getinfo is kind of my only hint.
The script works on other websites.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:46:47+00:00Added an answer on May 22, 2026 at 2:46 am

    Note the status code, which is a 302 Found, meaning that the page is issuing a redirect. Try:

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    

    This will make cURL follow the redirects for you, and should fix this issue.

    (Error: 1 is irrelevant, that’s just because you’re doing echo print_r().)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to get to a page straight from Bash at http://www.ocwconsortium.org/ . The
When I try user = System.Web.UI.Page.CurrentUser or user = System.Web.UI.Page.User.Identity I get an error
I have a function in Jquery, that try get html from an page: $.ajax({
When I try to open a project's CodeAnalysis page I get the error An
I get this wired error only when I try to access the web page
when i try to do this and load the webforms page, i get this
I am working on a C++ program, which uses cURL lib. When I try
i get page in utf-8 with russian language using curl. if i echo text
I get result to JavaScript from native NPAPI/XPCOM/ActiveX. Previously user activate native GUI by:
Is it possible to get page title via iText ? The PdfTextExtractor returns all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.