cURL question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Oxydude
Forum Newbie
Posts: 22
Joined: Sun Aug 01, 2004 9:57 am

cURL question

Post by Oxydude »

I am trying to use curl to access a webpage. When I try to get information about a particulat item:

curl http://catalog.bigcompany.com/cgi-bin/c ... a=chair123

it redirects me to a login website and returns the following:

The document has moved <A HREF="/noauth/bclogin.php?return=/cgi-bin/catalog?va=chair123">here</A>.<P>

From the source code for the form, the table information is:
<input type=text name=usermail "myemail@domain.com">
<input type=password name=userpass value="pass123">
<input type=hidden name=nocookies value="")
<input type=hidden name=enterkey value="hit")
<input type=submit name=userlogin value="login")

When this is entered through a webpage, the next page served is the chair123 page after I enter my name and password.

I just want to use curl from the command line to achieve this; first manually and then to integrate the command into my script.

Any ideas on how to do this?
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

You have to use curl to go to the login page, capture the session cookie sent back to you and then send it along with any subsequent requests.

I've never used curl so I don't know the mechanics, I've done it the hard way using fsockopen.
Oxydude
Forum Newbie
Posts: 22
Joined: Sun Aug 01, 2004 9:57 am

Post by Oxydude »

Thanks hedge, I will give it a shot!
Oxydude
Forum Newbie
Posts: 22
Joined: Sun Aug 01, 2004 9:57 am

Hedge

Post by Oxydude »

Hedge,

I found something you wrote in March that I will try tonight:


viewtopic.php?t=7063

I think this is exactly what will work.

Thanks!
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

From what I understand I did it the hard way. You may want to look at snoopy (source forge) or continue with CURL.
Oxydude
Forum Newbie
Posts: 22
Joined: Sun Aug 01, 2004 9:57 am

Post by Oxydude »

I will look into snoopy. Thanks for the tip.
Post Reply