![]() |
How to get XML with PHP from armory
*Update*
Since my old tutorial files are lost I made some new ones. You can check them out here: php_ajax_armory_tutorial - rothui - Google Code Three files are needed. - A basic PHP file that does the structure and includes links that will call your AJAX function guild_data.php - rothui - Google Code - Some JavaScript functions to retrieve stuff armory.js - rothui - Google Code - Another PHP file that is called by the AJAX function and retrieves the information for you get_char_data_xml.php - rothui - Google Code As some posts on page 3 already have mentioned we are now using a class that contains the retrieved information. If your webserver does not support CURL you can try this function to get the XML string instead. If it does support CURL you should make use of it. PHP Code:
Oh btw...Don't spam the armory server with requests or you will find yourself banned temporarily shortly after. |
Thanks for this. I had originally intended to do some playing with data from the Armory but PHP (and web development in general) is not something I have much experience with so I never got sufficiently motivated to do it. I think this will give me the impetus to have another go as it means I don't need to spend ages working out how to get the data and concentrate on the manipulation of it.
|
Just to give you some quick example what can be done:
http://dm.next-gen.org/files/item_to...980&lang=fr-fr http://dm.next-gen.org/files/item_to...980&lang=de-de http://dm.next-gen.org/files/item_to...980&lang=en-en Source: http://dm.next-gen.org/files/item_tooltip_xml.html So you could have tooltips for every item id you want in multiple languages with just one little script that you could call with AJAX in real time. If you want to lookup for items per "name", no problem. I want every item with "onslaught" in it. (beware of browser language!) http://armory.worldofwarcraft.com/se...uery=Onslaught Ok now with the php script: http://dm.next-gen.org/files/item_qu...en&q=onslaught http://dm.next-gen.org/files/item_qu...de&q=onslaught http://dm.next-gen.org/files/item_qu...fr&q=onslaught Just have the query string you are searching for behind the "q=". Source: http://dm.next-gen.org/files/item_query_xml.html Thats it. |
I admit I haven't done any XML parsing yet, but did you take a look at http://www.php.net/manual/en/ref.xml.php?
You should be able to read XML files without having to convert them. BTW, those links don't work for me: http://dm.next-gen.org/files/item_qu...en&q=onslaught |
Quote:
|
I'm getting the following error, but it's probably because I don't know what I'm doing.
![]() |
http://phparmory.sourceforge.net/ or http://sourceforge.net/projects/phparmory/ is a parse I found around the net that puts everything into php arrays. It's pretty neat and easy to add in your own code (if you know a bit of PHP). I added in some code to get Arena Teams for use on my guilds under dev new layout and it works nice.
|
I use cURL to pull down the xml and simplexml to parse it for my guilds roster page. Requires PHP5, which most webhosts haven't switched to (including our host). I run the script below on my desktop that has PHP5, it parses the info I need and puts it into a mysql database at our host. Then on our hosts server with PHP4, roster.php parses the data from the mysql database.
PHP Code:
Hope this is helpful. |
I was mucking around testing with Firefox, IE7 and Safari for Windows today and I happened to notice Safari is awesome for using the armory (mostly). Firefox and IE7 will choke/lock up on the large xmlhttprequests and not respond until they have finished loading/processing the page. Safari however will let you carry on no problems, opening new tabs etc while the armory is loading in the background tab.
It's a pain Safari doesn't render text white in input boxes though :( |
Quote:
Weird, normally Firefox displays the XML data and doesn't just put out a blank page. |
Quote:
So it doesn't matter that you do not see nothing. Just look into the source to see the XML. The Armory XML is very very fast, what makes the application so slow is all the AJAX crap. It just eats the browser alive >_<. @renew Thanks for the link I will take a closer look at this one. I am now at the point where I have to transfer the XML data into PHP arrays. |
Thanks for the insight zork. I'll begin the c# asp.net port shortly. There's probably already one out there but I'm bored.
|
1 Attachment(s)
Quote:
Code:
static HttpWebRequest RequestBuilder(string requestUri, string currentPage, string referer, string address)I would call it like: Code:
HttpWebRequest request = RequestBuilder("http://" + address + "/guild-info.xml?r=" + serverName + "&p=1&n=" + guildName + "&lang=", @"guild-info.xml%3Fr%3D" + serverName + "%26n%3D" + guildName + "%26p%3D1", @"http://" + address + "/#guild-info.xml?r=" + serverName + "&n=" + guildName + "&p=1", address);EDIT: I attached the source to my armory parse. It's pretty ugly and completely devoid of comments since it's something I hacked up in an afternoon and never really bothered with again. Hopefully someone can get some value out of the source however. |
I just want to give you an update on this to show what amazing stuff can be done.
I built our own item search based on the Armory XML, take a look :) ![]() All data is generated in real time, no database is used. p.s. I couldn't use the phparmory XML parser, sadly it had a bug with XML attributes. But i found another one that worked properly and nearly the same. |
Quote:
|
| All times are GMT -4. The time now is 2:40 AM. |
Forum Infrastructure by vBulletin 3.6.12 ©2000-2007, Jelsoft Enterprises Ltd.