stigen Posted July 26, 2008 Share Posted July 26, 2008 Here is my code: <?php // create a new cURL resource $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://speed.travian.co.uk"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookiejar'); $frontpage = curl_exec($ch); $tokens = array(); //Hent inn hidden validation fields //preg_match('/ id="__VIEWSTATE" value="([^"]+)"/', $frontpage, $tokens['viewstate']); //type="hidden" name=" //name="login" value=" preg_match('/type="text" name="([^"]+)"/', $frontpage, $tokens['name']); preg_match('/type="password" name="([^"]+)"/', $frontpage, $tokens['name']); preg_match('<p align="center"><input type="hidden" name="([^"]+)"/', $frontpage, $tokens['ting']); //preg_match('/name="login" value="[^"]+)"/', $frontpage, $tokens['lol']); $tokens['name'] = $tokens['name'][1]; $tokens['pass'] = $tokens['pass'][1]; $tokens['ting'] = $tokens['ting'][1]; $tokens['lol'] = $tokens['lol'][1]; curl_setopt($ch, CURLOPT_URL, "http://speed.travian.co.uk"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookiejar'); $post = '$w=1440:900'; $post .= '&$tokens[name]=******'; $post .= '&$tokens[pass]=******'; $post .= '&login='.time(); $post .= '&s1.x=53'; $post .= '&s1.y=10'; $post .= '&s1=login'; curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiefil); //curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiefil); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $dorf1 = curl_exec($ch); curl_setopt($ch, CURLOPT_URL, "http://speed.travian.co.uk/dorf1.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookiejar'); $no = curl_exec($ch); echo "$no"; $time = time(); echo "<br><br><br><br>$time"; What I'm trying to do is: login to speed.travian.co.uk and hopfully later do more things.... Link to comment https://forums.phpfreaks.com/topic/116751-help-with-curl/ Share on other sites More sharing options...
discomatt Posted July 26, 2008 Share Posted July 26, 2008 https://addons.mozilla.org/en-US/firefox/addon/3829 Grab that... login manually, and copy the post strings exactly as you request the pages. Your method looks fine, but you may be grabbing/posting the wrong values. Link to comment https://forums.phpfreaks.com/topic/116751-help-with-curl/#findComment-600390 Share on other sites More sharing options...
stigen Posted July 27, 2008 Author Share Posted July 27, 2008 well the s1.x and s1.y changes every time :S That's the problem :S Link to comment https://forums.phpfreaks.com/topic/116751-help-with-curl/#findComment-600587 Share on other sites More sharing options...
stigen Posted July 27, 2008 Author Share Posted July 27, 2008 Bump I really need help here Link to comment https://forums.phpfreaks.com/topic/116751-help-with-curl/#findComment-600913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.