09-07-2010, 07:56 AM
|
#139 (permalink)
|
|
The Visitor
Join Date: Apr 2010
Posts: 3
Thanks: 0
|
I am loving the work that has been done so far on the cURL scripts. I have been viewing and using this topic myself and have produced my own data grabber for the Armory, I really want to take it a stage further than what it is and grab item info and also professions and specs of my character. I was wondering how this could be achived? I note that there are comments about about how to get the profession data and such but for the life of me I cannot get them to work and could use some help.
Here is my code for what I am doing, I have opted not to use the switches and case functions ofr this example to keep the code short in the thread :)
PHP Code:
function fetchXML($url)
{
//initialize library
$ch = curl_init();
//used to make us look like a browser
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
//set the url
curl_setopt ($ch, CURLOPT_URL, $url);
//set that I want to wait for a response
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
//make us look like a web browser
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
//get data
$data = curl_exec($ch);
//clean up
curl_close($ch);
///return xml data
return $data;
}
define("USE_CURL", true);
//set character and realm info
$realm = "Nordrassil";
$character = "Necroshen";
$url = "http://eu.wowarmory.com/character-sheet.xml?r=" . $realm . "&n=" . $character ;
//get xml doc with character info
$data = fetchXML($url);
//create a SimpleXML object to parse the xml
$profile_xml = new SimpleXmlElement($data);
Where to look for the data
PHP Code:
foreach ($profile_xml->characterInfo->character as $char){
$charclass = return_class($char['classId']);
$charrace = return_race($char['raceId'], $char['genderId']);
$charrank = return_rank($char['rank']);
}
Display the data
PHP Code:
{
echo "<li>{$char['name']}</li>";
echo "<li>{$char['level']}</li>";
echo "<li>{$char['battleGroup']}</li>";
echo "<li>{$char['faction']}</li>";
echo "<li>{$char['prefix']}</li>";
echo "<li>{$char['guildName']}</li>";
echo "<li>{$char['race']}</li>";
echo "<li>{$char['realm']}</li>";
echo "<li>{$char['class']}</li>";
}
What I am looking to do now is pull item data and also profession and spec data as well and I need to know how do to that as I cannot get the above examples to work. 
|
|
|
|