TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 08-24-2008, 09:00 PM   #1 (permalink)
The Contributor
 
mortisimus's Avatar
 
Join Date: Sep 2007
Location: London, UK
Posts: 47
Thanks: 4
mortisimus is on a distinguished road
Default World of Warcraft Armory xml Grabber with cURL

Ok, I ran across this a little while ago and since I spent a lot of time looking for this, I thought I would share this with all you guys here that want it.

PHP Code:
class armory {

 const 
BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";

 public 
$query;
 public 
$server;
 public 
$guild;
 public 
$guildie;
 public 
$page;

public function 
__construct $query$server$guild$guildie$page ) {
    
$this->query $query;
    
$this->server $server;
    
$this->guild $guild;
    
$this->guildie $guildie;
    
$this->page $page;
 } 
// end of __construct()

public function pull_xml() {

    
// change the first part of the $url to the armory link that you need
    
if( $this->query === 'roster' ){
        
$url 'http://eu.wowarmory.com/guild-info.xml?r=' urlencode($this->server) . '&n=' urlencode($this->guild) . '&p=' $this->page;
        
      }elseif( 
$this->query === 'character' ){
        
$url 'http://eu.wowarmory.com/character-sheet.xml?r=' urlencode($this->server) . '&n=' $this->guildie;
        
        }  

    
$ch curl_init();
    
curl_setopt ($chCURLOPT_URL$url);
    
curl_setopt ($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt ($chCURLOPT_CONNECTTIMEOUT15);
    
curl_setopt ($chCURLOPT_USERAGENT,  self::BROWSER);
    
    
$url_string curl_exec($ch);
    
curl_close($ch);
    return 
simplexml_load_string($url_string);
    
   
 } 
// end of pull_xml()

// end class 
And then to use it:

PHP Code:
Syntax:
$armory = new armory( [character or roster] , realm , [guild name or NULL] , character name , [page number (guilds only) or NULL];

Example:
$armory = new armory(characterhellscreamNULLmortisimusNULL);
$xml $armory->pull_xml(); 
Then you could var_dump($xml) to see all the options you can pull from the armory.

Another example (to get the name):
PHP Code:
$armory = new armory(characterhellscreamNULLmortisimusNULL);
$xml $armory->pull_xml();
echo 
$xml->characterInfo->character['name']; 
Which will get the value of the name in the character tag, contained in the characterInfo tag in the xml file from the armory or in short, the characters name

All simple stuff but it helped me out.

The World of Warcraft Armory - EU
The World of Warcraft Armory - US

Last edited by mortisimus : 11-09-2008 at 09:43 AM.
mortisimus is offline  
Reply With Quote
The Following 7 Users Say Thank You to mortisimus For This Useful Post:
argantes (04-24-2009), codefreek (07-29-2009), Mithadriel (11-08-2008), sketchMedia (08-31-2008), Tanax (11-09-2008), Wildhoney (08-25-2008), Yinx (02-09-2009)
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:05 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design