Ok, going to revive this thread as I am still working on this and I thought it better here than going through a whole new batch of inquiries.
Now your all going to get a good laugh, at my expense. Here I thought that fictional characters and fictional junk didn't need security. Come to find out, some users (not all, its an optional feature) have two-part authentication to get in to their game accounts. I think my brain short circuited on that and now I can't figure out why I am having a strange issue.
First my original question of how to get the XML was tied to the use of CURLOPT_USERAGENT. Their site checks your browser to see if your browser can support XML.
<?php
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$authenticate = $_POST['authenticate'];
$loginvars = "accountName=" . $username . "&password=" . $password;
define(WOW_LOGIN_URL, 'https://www.blizzard.com/login/login.xml?referer=http%3A%2F%2Fwww.wowarmory.com%2Fvault%2Fguild-bank-log.xml%3Fr%3DThe%2BRealm%26n%3DThe%2BGuild&loginType=com');
$ch = curl_init(WOW_LOGIN_URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $loginvars);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, '../hidden/cookie.txt');
$results = curl_exec($ch);
curl_close($ch);
if (strstr($results, "Invalid account name or password")) {
echo "Invalid account name or password<br>";
}
elseif (strstr($results, "Account name required")) {
echo "Invalid account name or password<br>";
}
elseif (strstr($results, "Password required")) {
echo "Invalid account name or password<br>";
}
elseif (strstr($results, "Authenticator code required")) {
echo "Invalid Authenticator code<br>";
}
elseif (strstr($results, "Login failed")) {
echo "Invalid account name or password<br>";
}
elseif (strstr($results, "Authenticator Code")) {
$loginauth = "authValue=" . $authenticate;
$ch = curl_init(WOW_LOGIN_URL);
curl_setopt($ch, CURLOPT_COOKIEFILE, '../hidden/cookie.txt');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $loginauth);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, '../hidden/cookie.txt');
$results = curl_exec($ch);
curl_close($ch);
echo $results;
}
else {
echo $results;
}
}
else {
?>
<html>
<body>
<form action="banklog.php" id="loginForm" method="post">
Account Name <input id="username"name="username" type="text" /><br>
Password <input id="password" name="password" type="password" /><br>
Authenticator <input id="authenticate" name="authenticate" type="text" /><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
}
?>
Now I can get the above code to work if the person is using the second form of authentication. But it will not get the XML for those that don't use the second form of authentication as I can not put the CURLOPT_USERAGENT in the first cURL options as it breaks the second cURL function, not allowing that user to finish logging in.
Any ideas on how to fix that?
PS
Sorry the code is a bit disheveled its just for testing and once working will be incorporated into the working environment.