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
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-11-2009, 06:16 PM   #81 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

Yea don't mind yinx. Some of are willing the give out 10 or 20 lines of code. I figure giving you a few lines of code is easier than you going and find some out of date and partially irrelevant code and asking us to look over 100's lines of code and help you find fix the problems.

Of course if you need a 100 lines of code for something I think may pass on that.
Krik is offline  
Reply With Quote
The Following User Says Thank You to Krik For This Useful Post:
commonmind (03-13-2009)
Old 03-11-2009, 08:15 PM   #82 (permalink)
The Wanderer
 
Join Date: Mar 2009
Posts: 20
Thanks: 5
commonmind is on a distinguished road
Default

Not a problem. I've worked through getting the data (thanks to the help of yourself and other members), now I'm just trying to figure out how to incorporate it into an HTML page so that I can actually view it and style it according to the rest of my site.

I found another tutorial out there that explained the process of creating a database to store the data, but I'm uncertain as to how to connect the two pieces together. I'm also not sure I really need the database, as I just want to display the roster and aren't too concerned with any more functionality beyond that.

Again, I think this comes down to my experience being in design, and not dynamic development. If I had the data there on the page I could wrap it in tags, create a table for it, etc., but as it stands now all I have is the PHP code, staring me right in the face and laughing at my ignorance, and the XML data which I can view through the "view source" function in any number of browsers.

I know there's probably something simple I'm missing. And someone else mentioned the snippets in previous posts would help me through the process, but unfortunately I haven't had any luck with that either.

I've definitely been getting my 25 dollars a month worth out of Lynda.com, lol. So far I've plowed through variables, strings, functions, arrays, booleans and nulls, if, else and elseif statements, as well as loops (the latter of which has also looped my brain, and will definitely require another dozen viewings or so before it starts to make sense).
commonmind is offline  
Reply With Quote
Old 03-11-2009, 11:25 PM   #83 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

Adding it to your page is real simple. Make sure first that the page you want to see it on is a .php file (roster.php). Then just pace the code were you need it to run

HTML Code:
<html>
<body>
<!-- your html-->
<?php
//the php
?>
<!-- more html-->
</body>
</html>
To display the roster straight from the WoW web site use this block of code form my earlier post
PHP Code:
$xml = new SimpleXMLElement($rosterxml);

foreach (
$xml->guild->members->children() as $char) {
    echo 
'Name: ' $char['name'] . ' ';
    echo 
'Class: ' $char['class'] . ' ';
    echo 
'Level: ' $char['level'] . ' <br>';

Were you see the "echo" in that block you can just "echo" out any html formatting for each characters info

PHP Code:
echo '<tr>
         <td class="roster">' 
$char['name'] . '</td>
         <td class="roster">' 
$char['class'] . '</td>
         <td class="roster">' 
$char['level'] . '</td>
      </tr>'

That will place each characters name, class and level in a table row.
Krik is offline  
Reply With Quote
The Following User Says Thank You to Krik For This Useful Post:
commonmind (03-13-2009)
Old 03-12-2009, 02:48 PM   #84 (permalink)
The Wanderer
 
Join Date: Mar 2009
Posts: 20
Thanks: 5
commonmind is on a distinguished road
Default

Thanks Krik. When I put the two blocks together, as follows (of course, inserting my own guild's name and server):

PHP Code:
<?php

$url 
'http://www.wowarmory.com/guild-info.xml?r=server=guildname&p=1';
    
$ch curl_init();
    
curl_setopt ($chCURLOPT_URL$url);
    
curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt ($chCURLOPT_USERAGENT,  "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
    
    
$rosterxml curl_exec($ch);
    
    echo 
$rosterxml;  
    
    
$xml = new SimpleXMLElement($rosterxml);

foreach (
$xml->guild->members->children() as $char) {
    echo 
'Name: ' $char['name'] . ' ';
    echo 
'Class: ' $char['class'] . ' ';
    echo 
'Level: ' $char['level'] . ' <br>';
}  
    
?>
I get this error:

Quote:
Fatal error: Call to a member function children() on a non-object in /home/enemy/public_html/roster.php on line 20
I haven't attempted to put in the table code yet.
commonmind is offline  
Reply With Quote
Old 03-12-2009, 05:02 PM   #85 (permalink)
The Wanderer
 
Join Date: Mar 2009
Posts: 20
Thanks: 5
commonmind is on a distinguished road
Default

I was just looking back through the thread for some pointers, and I don't think I posted a link to my site in any of my messages. It's nothing fancy, and all of it is of course CSS/HTML -- definitely not as dynamic as some of the examples I've seen from this community -- but here it is.

Looking over some of the other threads throughout the forums, and after watching and reading some of the extensive PHP tutorials out there, I've gotten inspired to create a custom CMS and do much more with the content on the site, including this roster page -- once I've gotten a handle on it.

I just wish I had realized earlier how much PHP could've opened me up to doing some truly creative things with previous sites I've built. Thankfully I can use the guild site as a sort of testing ground for some of these new endeavors.
commonmind is offline  
Reply With Quote
Old 03-13-2009, 05:36 AM   #86 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

The problem your having is fairly simple, if you have bit more knowledge in DOM (document object model) you would have seen it. Of course if I would have tested before giving it to you I would have seen it also.

The "$xml->guild->members->children()" isn't quite right the parent node of "guildInfo" was overlooked when I wrote that. So it should have been "$xml->guildInfo->guild->members->children()"

So all of it together would be
PHP Code:
<?php
$url 
'http://www.wowarmory.com/guild-info.xml?r=YOUR+SERVER=YOUR+GUILD&p=1';

$ch curl_init();
    
curl_setopt ($chCURLOPT_URL$url);
    
curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt ($chCURLOPT_USERAGENT,  "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");

$rosterxml curl_exec($ch);  

$xml = new SimpleXMLElement($rosterxml);

foreach (
$xml->guildInfo->guild->members->children() as $char) {
    echo 
'<b>Name:</b> ' $char['name'] . ' ';
    echo 
'<b>Class:</b> ' $char['class'] . ' ';
    echo 
'<b>Level:</b> ' $char['level'] . ' <br>';

?>
I also took out the "echo $rosterxml;" as you don't need to echo the data twice.
Krik is offline  
Reply With Quote
The Following 2 Users Say Thank You to Krik For This Useful Post:
commonmind (03-13-2009), crispus (04-22-2009)
Old 03-13-2009, 05:45 AM   #87 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

Quote:
I just wish I had realized earlier how much PHP could've opened me up to doing some truly creative things with previous sites I've built. Thankfully I can use the guild site as a sort of testing ground for some of these new endeavors.
Yea and you are just beginning. PHP is truly key to having very powerful and dynamic sites. What you will learn as you go will help you in picking up other languages like SQL and Javascript, as well. And one day down the road you'll wake up and realize that if it can be done with a web site you are able to do it.
Krik is offline  
Reply With Quote
The Following User Says Thank You to Krik For This Useful Post:
commonmind (03-13-2009)
Old 03-13-2009, 05:57 AM   #88 (permalink)
The Wanderer
 
Join Date: Mar 2009
Posts: 20
Thanks: 5
commonmind is on a distinguished road
Default

Thanks so much Krik, worked flawlessly. I'll take some time and try and understand a bit of what's going on in the above code (thankfully I recognize a good deal more of it now), style the page, and post some results. I definitely want to wrap my head around this concept a little more before I start tackling a dynamic calendar and actually utilizing databases and the like. :)

Thanks for the help, again, very appreciated. Also, do you have any other recommendations for tutorials, maybe a place where you got started that helped you along? The Lynda videos are nice, but being a good 12 hours in I'm also noticing they're very concise, and I'd like something a little more comprehensive.
commonmind is offline  
Reply With Quote
Old 03-13-2009, 06:00 AM   #89 (permalink)
The Wanderer
 
Join Date: Mar 2009
Posts: 20
Thanks: 5
commonmind is on a distinguished road
Default

Quote:
Originally Posted by Krik View Post
Yea and you are just beginning. PHP is truly key to having very powerful and dynamic sites. What you will learn as you go will help you in picking up other languages like SQL and Javascript, as well. And one day down the road you'll wake up and realize that if it can be done with a web site you are able to do it.
I think that's the most exciting part. I admit that I didn't give PHP any real attention before. I assumed it was just a solid architecture for web forums. That was until I started paying attention, came across sites which were extremely robust and delivered content in tons of different ways...and all of them built with PHP.
commonmind is offline  
Reply With Quote
Old 03-13-2009, 07:30 AM   #90 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

Tutorials, whenever I needed one I just google it of course I google for them based on the function I need so my search will look like "php mysql_fetch_array" which returns things on working with MySQL.

But the best resource is the php.net website. This is the home of PHP you can look up any function and get examples as well as there is tons of user comments with examples. If you have to go beyond their site for info on functions or doing something you may as well post in these forums as anything else out there is not going to be much more in depth that what they have.
Krik is offline  
Reply With Quote
Old 03-13-2009, 10:58 AM   #91 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Tutorials:
www.pixel2life.com (go to PHP category)
www.good-tutorials.com (go to PHP category)
www.nettuts.com has php tutorials occasionally
www.talkphp.com is a great site(well duuh). There's tutorials in the article section, and also there are tutorials in advanced php category of the forum, even in the basic php category of the forum. I've posted some tutorials here on the advanced php section.

Talkphp is also a great resource when you've hit an error you can't figure out on your own - just post it here and someone will reply.

For looking up functions, I'd just go with www.php.net - it's by far the best site with information about that. In top right corner, just search your function.

Anyways, this was some information about resources, hope this helps
Also - we're quite offtopic now, so if you need more information about phpresources I suggest you open an own thread in general, or just PM someone(like me for example xD)
__________________
Tanax is offline  
Reply With Quote
Old 03-13-2009, 01:50 PM   #92 (permalink)
The Wanderer
 
Join Date: Mar 2009
Posts: 20
Thanks: 5
commonmind is on a distinguished road
Default

I apologize for the massive derailing. And thanks again for the help, the both of you.
commonmind is offline  
Reply With Quote
Old 04-01-2009, 03:37 AM   #93 (permalink)
The Visitor
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Jamezy91 is on a distinguished road
Default

Hi all,
Okay i've been trying to use this script for my guild roster but i've run into a little snag... The foreach() loop doesn't like my guild name cause it has the special character Ú in it... Is there any way to get the script to accept that character? Any help would be appreciated...

My work around works fine but I don't want to have to edit my SQL every time someone join's...

Here's my work arround
PHP Code:
    $query "SELECT * FROM guild"//Main Query
        
$result mysql_query($query) or die('Error, query failed'); //Parse results
        
while($row mysql_fetch_array($result)){ 
        echo 
'<tr>';
    
    
$armory = new armory(charactermalfurionNULL$row['name'], NULL);
    
$xml $armory->pull_xml();
        echo 
'<td>    <div class="roster-text-wrapper">'$xml->characterInfo->character['name'] .'</div></td>';  
        echo 
'<td>    <div class="roster-text-wrapper">'$xml->characterInfo->character['class'] .'</div></td>';  
        echo 
'<td>    <div class="roster-text-wrapper">'$xml->characterInfo->character['level'] .'</div></td>';  
        echo 
'<td>    <div class="roster-text-wrapper">'$xml->characterInfo->character['realm'] .'</div></td>';  
        echo 
'<td>    <div class="roster-text-wrapper">'$xml->characterInfo->character['guildName'] .'</div></td>';  
        echo 
'<td>    <div class="roster-text-wrapper">'$xml->characterInfo->character['race'] .'</div></td>';  
        echo 
'<td>    <div class="roster-text-wrapper">'$xml->characterInfo->character['gender'] .'</div></td>';  
    
    echo 
'</tr>';
    } 
Edit: no matter what I try in the guild field in the script it won't display and when I use the foreach loop it errors out saying "Invalid argument supplied for foreach()" I've done countless google searches and poured through pages of stuff but have yet to find and answer... I know its that special letter cause when i put in someone elses guild name it shows right up...

Last edited by Jamezy91 : 04-03-2009 at 02:04 AM.
Jamezy91 is offline  
Reply With Quote
Old 04-10-2009, 02:15 AM   #94 (permalink)
The Visitor
 
Join Date: Nov 2008
Posts: 4
Thanks: 0
TheMuffinMan is on a distinguished road
Default

Anyone had any luck getting the "login required" pages to work with the new blizzard authentication?

I have been tinkering away at it (already have a roster up and running) but I haven't been able to crack it yet.
TheMuffinMan is offline  
Reply With Quote
Old 04-11-2009, 06:04 PM   #95 (permalink)
The Visitor
 
Join Date: Nov 2008
Posts: 4
Thanks: 0
TheMuffinMan is on a distinguished road
Default

w00t Krik! I figured it out! Here is the code used to access authentication required pages on the armory. (you know longer have to code for the Blizzard Authenticator as its requirement to login to the armory has been removed.)

PHP Code:
<?php
if (isset($_POST['submit'])) {

$username $_POST['username'];
$password $_POST['password'];

$loginvars "accountName=" $username "&password=" $password;

define(WOW_LOGIN_URL'https://us.battle.net/login/login.xml?ref=http%3A%2F%2Fwww.wowarmory.com%2Fvault%2Fguild-bank-log.xml%3Fr%3DMy%2BRealm%26n%3DMy%2BGuild&app=armory&loginType=com');

    
$ch curl_init(WOW_LOGIN_URL);
    
curl_setopt($chCURLOPT_POST1);
    
curl_setopt($chCURLOPT_POSTFIELDS$loginvars);
    
curl_setopt($chCURLOPT_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($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_HEADER0);
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt($chCURLOPT_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>";
    }
    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>

<input type="submit" name="submit" value="Submit">

</form>
</body>
</html>
<?php
}
?>
TheMuffinMan is offline  
Reply With Quote
Old 04-22-2009, 02:53 PM   #96 (permalink)
The Visitor
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
labluegirl is on a distinguished road
Default

hi, i wonder how to get achievements from armory?

Is it possible???

The url i found is :
$url = 'http://eu.wowarmory.com/character-achievements.xml?r=' . urlencode($this->server) . '&cn=' . $this->guildie.'&gn=' . urlencode($this->guild);

but it doesn't work...
labluegirl is offline  
Reply With Quote
Old 04-22-2009, 03:37 PM   #97 (permalink)
The Wanderer
 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Yinx is on a distinguished road
Default

The character achievement url is changed.

$url = 'http://eu.wowarmory.com/character-achievements.xml?r=' . urlencode($this -> server) . '&n=' . $this -> guildie;
Yinx is offline  
Reply With Quote
Old 04-22-2009, 03:47 PM   #98 (permalink)
The Visitor
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
labluegirl is on a distinguished road
Default

hmm i don't understand how to use it :x

$xml->achievements->rootCategories-> then?
labluegirl is offline  
Reply With Quote
Old 04-22-2009, 04:25 PM   #99 (permalink)
The Visitor
 
Join Date: Apr 2009
Posts: 3
Thanks: 0
labluegirl is on a distinguished road
Default

http://eu.wowarmory.com/character-ac...Absolute&c=168

this link is working but i don't know how to grab data in php...
labluegirl is offline  
Reply With Quote
Old 04-22-2009, 10:14 PM   #100 (permalink)
The Visitor
 
Join Date: Apr 2009
Posts: 3
Thanks: 2
crispus is on a distinguished road
Default

Quote:
Originally Posted by Krik View Post
The problem your having is fairly simple, if you have bit more knowledge in DOM (document object model) you would have seen it. Of course if I would have tested before giving it to you I would have seen it also.

The "$xml->guild->members->children()" isn't quite right the parent node of "guildInfo" was overlooked when I wrote that. So it should have been "$xml->guildInfo->guild->members->children()"

So all of it together would be
PHP Code:
<?php
$url 
'http://www.wowarmory.com/guild-info.xml?r=YOUR+SERVER=YOUR+GUILD&p=1';

$ch curl_init();
    
curl_setopt ($chCURLOPT_URL$url);
    
curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt ($chCURLOPT_USERAGENT,  "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");

$rosterxml curl_exec($ch);  

$xml = new SimpleXMLElement($rosterxml);

foreach (
$xml->guildInfo->guild->members->children() as $char) {
    echo 
'<b>Name:</b> ' $char['name'] . ' ';
    echo 
'<b>Class:</b> ' $char['class'] . ' ';
    echo 
'<b>Level:</b> ' $char['level'] . ' <br>';

?>
I also took out the "echo $rosterxml;" as you don't need to echo the data twice.
I tried using the code that you've posted here, and I'm still experiencing the same "Fatal error: Call to a member function children() on a non-object in" error. Any ideas on what could be causing this? Thanks a lot in advance!
crispus is offline  
Reply With Quote
Reply



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 05:31 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