cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Using cURL to Retrieve Data from Password-Protected Sites

From: Meghan Edmonds <medmonds_at_choicemeddata.com>
Date: Mon, 18 Dec 2006 15:28:21 -0500

Hello. I am trying to build an application that will allow me to search
a manufacturer's product manual for a particular item and return the
result in order to automate a data verification process. The
manufacturer's product catalog requires a login to gain access. I'm
having difficulty writing the code that will log in to the site so that
I can execute a search. Here is what I have so far:

$base_url = "https://www.site.com/dir";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $base_url);
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, TRUE);
curl_setopt($ch, CURLOPT_USERPWD, "[username]:[password]");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

I am getting a "302 Moved Temporarily" header. The body returns "This
document you requested has moved temporarily. It's now at..." I am new
to this and do not fully understand what this means, but from what I've
read here I believe it has to do with the cookie that is being created.
If I uncomment the CURLOPT_FOLLOWLOCATION line, it routes me to the
login page of the site.

If anyone could help explain this to me or assist me with the login
process, I would be very appreciative. Thank you,

-- 
Meghan
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-12-18