Rezert Posted June 20, 2008 Share Posted June 20, 2008 Okay, so I'm pretty good with PHP, including cURL, MySQL, GD Library, and REGEX. I'm not the best though. Now I remember when I was like 10 (2 years ago) I wanted to make a Neopets! portal I saw on some sites. However, I only new HTML. Now here's what it's supposed to display: Snowager is Awake/Sleeping The Current Band Is: (Current Band) And a couple things like that. Now my only problem is that I can't figure out how to login to Neopets w/ cURL because the login form is two pages long. Any help would be greatly appreciated, Rez Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/ Share on other sites More sharing options...
DarkerAngel Posted June 20, 2008 Share Posted June 20, 2008 On the hi.html page there is a hidden field named username If you are as good as you say you are you should be able to pick it up from there. Also if your a FF user and you tend to use cURL a lot, might I suggest this plugin: https://addons.mozilla.org/en-US/firefox/addon/966 Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/#findComment-570119 Share on other sites More sharing options...
Rezert Posted June 20, 2008 Author Share Posted June 20, 2008 Ah yes, I used to have that but I forgot to install it. Thanks a lot, I should be able to figure something out. =] Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/#findComment-570122 Share on other sites More sharing options...
Rezert Posted June 20, 2008 Author Share Posted June 20, 2008 Okay, I just came across a second problem. I tried doing this: <?php /****************************************************************** * Script created by Rezert * * Script created for everyone at www.virtualpetlist.com and * * www.mlfmp.com * * * * Contact Me: * * AIM: LethalLiquid * * MSN: [email protected] * * YIM: LethalLiquid * * * * Thanks to DarkerAngel * * of www.phpfreaks.com for showing me the hidden field * *****************************************************************/ $title = "Neopets! Portal"; // Title of the portal. $url = "http://mlfmp.com/"; // Your main website's URL. $user = "RezzyBoy"; // A neopets username. (Needed to check some data.) $pass = "password"; // The account's password. (Needed to check some data.) $refun = "RezzyBoy"; // Your username for the refferal page. $links = array( "Home" => $url, "Dailies" => "dailies.php", "Neopets Login" => "http://www.neopets.com/loginpage.phtml", "Neoepts Signup" => "http://www.neopets.com/refer.phtml?username=" . $refun ); // Links that will be displayed // DO NOT EDIT BELOW TIHS LINE \\ $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)"; $cl = curl_init(); curl_setopt($cl, CURLOPT_URL, "http://www.neopets.com/login.phtml"); curl_setopt($cl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($cl, CURLOPT_USERAGENT, $agent); curl_setopt($cl, CURLOPT_REFERER, "http://www.neopets.com/hi.phtml"); curl_setopt($cl, CURLOPT_POST, 1); curl_setopt($cl, CURLOPT_POSTFIELDS, "username=" . $user . "&password=" . $pass); curl_setopt($cl, CURLOPT_COOKIEJAR, "cookies"); curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1); $retlogin = curl_exec($cl); curl_close($cl); ?> and my second page has this: <?php include "config.inc.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.neopets.com/winter/snowager.phtml"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_REFERER, "http://www.neopets.com/login.phtml"); curl_setopt($ch, COOKIEFILE, "cookies"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $retsnow = curl_exec($ch); curl_close($ch); unset($ch); if(preg_match('/That <font color="#FF0000"><strong>username\/password<\/strong><\/font> combination is invalid./', $retlogin)) { die("This script was configured incorrectly. Please enter a valid username and password in the config.inc.php"); } if(preg_match('/The Snowager is awake!!! You better run before it eats you!!!/', $retsnow)) { $snow = "The snowager is awake."; } else { $snow = "The snowager is asleep."; } echo $snow; unlink("cookies"); ?> Now the problem is it's saying "The snowager is asleep." when it's really awake. So I echo()ed $retsnow and it shows the login form. I'm like WTF!?!?! because I logged in with config.inc.php Any help would be muchly appreciated, Rezert And before you say it's cuz $pass = "password"; I just changed that... Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/#findComment-570269 Share on other sites More sharing options...
DarkerAngel Posted June 20, 2008 Share Posted June 20, 2008 2 things. 1. I always have my post fields in an array, not a query string, when using cURL $postfields = array( 'username' => 'username', 'password' => 'password', 'destination' => '%2Findex.phtml'); 2. The login page is expecting the 'destination' variable it may not be returning the proper cookies if that's not set Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/#findComment-570283 Share on other sites More sharing options...
Rezert Posted June 20, 2008 Author Share Posted June 20, 2008 I have never used arrays in it though. o.0 I just display $retlogin and it looks like it's logging in fine...I'm very confused now. Oh yeah, I added the destination part also. Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/#findComment-570290 Share on other sites More sharing options...
Rezert Posted June 20, 2008 Author Share Posted June 20, 2008 I took out the unlink("cookies") and went to that file...it looks like this: # Netscape HTTP Cookie File # http://www.netscape.com/newsref/std/cookie_spec.html # This file was generated by libcurl! Edit at your own risk. .neopets.com TRUE / FALSE 1245511475 np_randseed 48209782833739562 .neopets.com TRUE / FALSE 1221975475 neoremember rezzyboy .neopets.com TRUE / FALSE 1205975475 wc_ids 0 .neopets.com TRUE / FALSE 1245511475 neologin rezzyboy%2BTT5ZZCFWMCZB9ZBB .neopets.com TRUE / FALSE 1221975475 toolbar rezzyboy%2BC%2Bce6e360dd6763e0d49759e192b8a8ef8 .neopets.com TRUE / FALSE 1213969476 nupi 0 .neopets.com TRUE / FALSE 1213969476 nupid 0 .neopets.com TRUE / FALSE 1213969476 npid 0 .neopets.com TRUE / FALSE 1245511476 np_uniq pending .neopets.com TRUE / FALSE 1245511476 xt6Yr4e33D 10296997547675126158185 .neopets.com TRUE / FALSE 1214061876 adnets_hash blsip_pixel%3A1213975476%7Erenew%3A1%7E Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/#findComment-570313 Share on other sites More sharing options...
Rezert Posted June 20, 2008 Author Share Posted June 20, 2008 I think I know what's wrong. I am including that login script on every page and I should only do it once...let me try this... Erm...no, that was not it...sorry for the triple post. I didn't realize lol...I'll edit from now on. Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/#findComment-570319 Share on other sites More sharing options...
Rezert Posted June 20, 2008 Author Share Posted June 20, 2008 It wouldn't let me edit... Anyways, I'll just create a function that logs in every time and just uses the page I need as the destination. Link to comment https://forums.phpfreaks.com/topic/111102-curl-problem/#findComment-570336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.