Solved

CURLOPT_HEADER returns 401

Posted on 2014-09-25
7
183 Views
Last Modified: 2014-10-01
I need to get the location header. From what I've read, this should be as simple as

curl_setopt($c, CURLOPT_HEADER, true);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, false);

Open in new window


If I don't include those two options, the curl request works fine, but I'm not able to get the location header.

If I do include those two options, then I get a 401 error.

The Location that is being returned should be a URL that does require an additional login. What am I doing wrong?
0
Comment
Question by:quizwedge
  • 4
  • 2
7 Comments
 
LVL 34

Assisted Solution

by:gr8gonzo
gr8gonzo earned 250 total points
ID: 40344907
The 401 code isn't an error. It's just the code that tells the browser to prompt for authentication. Are you looking for a URL that happens AFTER login?
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 40344924
By themselves, these two instructions don't tell us much.  What is the URL you're making the request to?  Why are you telling cURL not to follow the location headers?
0
 
LVL 14

Accepted Solution

by:
quizwedge earned 0 total points
ID: 40346289
In generating the needed information for a response, I figured out my issue. I wasn't thinking about previous requests. Looking too much at the trees to see the forest.

I have to make a call to get a session token and then use that session token to make my PUT call. Since I wasn't parsing out the headers from the previous request, I wasn't successfully grabbing the session token. Everything is working now.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 14

Author Comment

by:quizwedge
ID: 40346466
I've requested that this question be closed as follows:

Accepted answer: 0 points for quizwedge's comment #a40346289

for the following reason:

The issue was a previous request. I didn't have enough information in the question to allow others to provide an answer and once I got that information, I was able to find the solution.
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 40346327
If our questions prompted you in a direction that led to the correct answer, I would consider awarding points to those comments.
0
 
LVL 14

Author Comment

by:quizwedge
ID: 40346467
It wasn't any one question that prompted me, but I'll split points.
0
 
LVL 14

Author Closing Comment

by:quizwedge
ID: 40354165
The issue was a previous request. I didn't have enough information in the question to allow others to provide an answer and once I got that information, I was able to find the solution.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question