$url = 'https://account.guildwars2.com/login';
$fields = array(
'email' => urlencode("<email>"),
'password' => urlencode("<password>"),
);
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_FAILONERROR => false,
CURLOPT_TIMEOUT => 10,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_HEADER => true,
CURLOPT_POST => count($fields),
CURLOPT_POSTFIELDS => $fields_string,
CURLOPT_REFERER => $url // Updated... but still doesn't get things rolling
);
static $headers = array(
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language: en-us,en;q=0.5",
// while we can get raw, we don't have to gunzip the response <3
"Accept-Encoding: deflate",
"Connection: keep-alive",
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1",
);
$options[CURLOPT_HTTPHEADER] = $headers;
$ch = curl_init($url);
curl_setopt_array($ch, $options);
preg_match('/^Set-Cookie: (.*?);/m', curl_exec($ch), $m);
var_dump(parse_url($m[1]));
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo "Status $http_status\n";
//close connection
curl_close($ch);
Edited by rp90, 25 September 2012 - 03:50 PM.










