Jump to content

Recommended Posts

Hey guys,

 

Long time no see!

 

OK here's my problem. I'm in the process of making a script to login to AffiliateWindow.com and download the report page. I've done lots of scripts like this before for other affiliate networks, but for some reason this one is causing problems.

 

My code:

 

<?php

$userid = "xxxxx";
$password = "xxxxx";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://www.affiliatewindow.com/login.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "orig_location=&back=%2Findex.php&user={$userid}&password={$password}&screenwidth=&screenheight=&colourdepth=&image2.x=0&image2.y=0");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$login = curl_exec($ch);

/* When I run a die($login) here, it shows the logged in account page perfectly */

curl_setopt($ch, CURLOPT_URL, "http://www.affiliatewindow.com/affiliates/commissions_report.php");
$report = curl_exec($ch);

/* When I run a die($report) here, I get nothing */

?>

 

^ Read the comments in the code to see the problem.

 

I really don't understand why I'm getting a blank page when I try and output $report... so any advice would be appreciated!

 

Cheers,

 

Charlie

Link to comment
https://forums.phpfreaks.com/topic/100947-curl-help-please/
Share on other sites

script may set a session variable on login which is not set or maintained on the second curl_exec(). not sure what to do, maybe there's session handling built in to curl.

 

Hey,

 

Thanks for the advice. A quick Google search didn't bring much up about sessions in cURL. :(

 

Charlie

Link to comment
https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516250
Share on other sites

Sessions shouldn't be a problem, since they store a cookie to track the session ID and you're allowing for cookies.

 

However, have you tried echoing curl_error() ?

 

Also, you may want to take a look at using the live HTTP headers extension for firefox. It shows you exactly whats being sent and returned to/from the server. It's useful to compare your manual request with the automated cURL request to make sure there's no differences.

 

You could also try making your request look more normal - provide a user agent, referrer etc.

Link to comment
https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516255
Share on other sites

Sessions shouldn't be a problem, since they store a cookie to track the session ID and you're allowing for cookies.

 

However, have you tried echoing curl_error() ?

 

Also, you may want to take a look at using the live HTTP headers extension for firefox. It shows you exactly whats being sent and returned to/from the server. It's useful to compare your manual request with the automated cURL request to make sure there's no differences.

 

You could also try making your request look more normal - provide a user agent, referrer etc.

 

Hey,

 

curl_error() is a good idea, I'll try that in a minute.

 

Is there any way I can get cURL to output the headers/information of what it's about to send so I'm able to compare it with the headers of the FireFox request?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516258
Share on other sites

I think you may also need to specify the COOKIEFILE option before your second request:

 

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");

 

Did you also add things like a referrer and user agent? Certain(bad) websites will check these and not show data if they're not present.

Link to comment
https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516828
Share on other sites

I think you may also need to specify the COOKIEFILE option before your second request:

 

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");

 

Did you also add things like a referrer and user agent? Certain(bad) websites will check these and not show data if they're not present.

 

Thanks for the advice.

 

I added the CURLOPT_COOKIEFILE line, to no avail.

 

And yes, I copied the headers from my FireFox and set a user agent, but this made no difference at all.

Link to comment
https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516836
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.