Jump to content

Help with curl :)


stigen

Recommended Posts

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....:P

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

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.