chigley Posted April 13, 2008 Share Posted April 13, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/ Share on other sites More sharing options...
BlueSkyIS Posted April 13, 2008 Share Posted April 13, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516235 Share on other sites More sharing options...
chigley Posted April 13, 2008 Author Share Posted April 13, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516250 Share on other sites More sharing options...
GingerRobot Posted April 13, 2008 Share Posted April 13, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516255 Share on other sites More sharing options...
chigley Posted April 13, 2008 Author Share Posted April 13, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516258 Share on other sites More sharing options...
chigley Posted April 13, 2008 Author Share Posted April 13, 2008 Just an update, curl_error() didn't return anything. Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516286 Share on other sites More sharing options...
chigley Posted April 14, 2008 Author Share Posted April 14, 2008 Don't suppose anyone else has any ideas as to how to go about solving my problem? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516609 Share on other sites More sharing options...
chigley Posted April 14, 2008 Author Share Posted April 14, 2008 Anyone? Sorry to keep bumping, just I'm worried it won't get seen and I'm really stuck! Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516823 Share on other sites More sharing options...
GingerRobot Posted April 14, 2008 Share Posted April 14, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516828 Share on other sites More sharing options...
chigley Posted April 14, 2008 Author Share Posted April 14, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-516836 Share on other sites More sharing options...
chigley Posted April 17, 2008 Author Share Posted April 17, 2008 Quick bump in case anyone's had a brainwave? Quote Link to comment https://forums.phpfreaks.com/topic/100947-curl-help-please/#findComment-519798 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.