Jump to content

CURL help (pleeeaaseee) :D


StirCrazy

Recommended Posts

Hi folks,

 

I'm trying login into a website and store a webpage (that contains a sales report) in a variable.

 

So far I can login using:-

curl_setopt($ch, CURLOPT_URL, $login_url);

curl_setopt ($ch, CURLOPT_POST, 1);

curl_setopt ($ch, CURLOPT_POSTFIELDS, $login_post);

curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookies!.txt');

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

 

But the reports page isn't the first page of the website. So I need to login, goto the reports page, submit the form details and capture the results in a variable.

 

What I need is to login in using:-

$login_url = Login Page

$login_post = Contains login $_POST details

 

This is the page with the reports FORM:-

$reports_page = The URL with the form to select report

 

post these details:-

$reports_post = Contains $_POST details

 

to this page

$contents_url = The URL that the $_POST details are sent to

 

 

...and store the results in $page_contents

 

 

 

Does that make any sense?

 

I hope someone can help  ;D

 

 

 

S.C>

 

 

Link to comment
https://forums.phpfreaks.com/topic/37784-curl-help-pleeeaaseee-d/
Share on other sites

You need to:

1) Go to the login page (that one the processes the login) and send the post data for a login.

2) Go to the page that processes the form and send the post/get data for it.

3) Do what ever you want with the result from part 2.

 

Now, most likely that either the site uses cookies for the login, or sessions and then sends you the session id (in most of the cases) in a cookie. So you need to use the CURLOPT_COOKIEFILE option in all of the curl requests. Add this to both of the requests:

curl_setopt ($ch, CURLOPT_COOKIEFILE, "tmp/some-random-name");

 

 

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.