Guild News feed example?

100 Draenei Shaman
11090
Trying to find examples on how to pull the Guild News feed with PHP. If anyone is using this on their site, or could post an example how to call the API, and a usage to pull the news, that would be great.
Edited by Dnul on 9/8/2012 1:21 PM PDT
Reply Quote
- Battle.net APIs
100 Night Elf Hunter
14895
/api/wow/guild/realmname/guildname?fields=members,news

ither use curl or get file contents and then json_decode and you have a workable php array :)

example of what can be done

http://beta.wowroster.net/guild/feeds/a=g:7.html
Reply Quote
100 Draenei Shaman
11090
I have the following:

$api_guild_news_url = "http://us.battle.net/api/wow/guild/Elune/Damnation?fields=news";

$file_contents = @file_get_contents($api_guild_news_url); // omit warnings

$guildNews = json_decode($file_contents, true);

How do I handle guildNews array? Or see what is in the array?
Reply Quote
- Battle.net APIs
100 Night Elf Hunter
14895
echo '<pre>';
print_r ($guildNews);
echo '</pre>';
that will print the array in a structure you can see better
Reply Quote
100 Draenei Shaman
11090
Awesome that works nicely....how do you handle the item name with the item id?
Reply Quote
100 Draenei Shaman
11090
Nevermind that, how do you get a color of an item, blue, rare, legendary?
Reply Quote
- Battle.net APIs
100 Night Elf Hunter
14895
quality switcher the numbers match a color for each item

function _getItemColor($value)
{
$ret = '';
switch ($value) {
case 5: $ret = "ff8000"; //Orange
break;
case 4: $ret = "a335ee"; //Purple
break;
case 3: $ret = "0070dd"; //Blue
break;
case 2: $ret = "1eff00"; //Green
break;
case 1: $ret = "ffffff"; //White
break;
default: $ret = "9d9d9d"; //Grey
break;
}

return $ret;
}
Reply Quote
100 Draenei Shaman
11090
You are so helpful, thank you :)
Reply Quote
100 Draenei Shaman
11090
How do you do achievements? I see that it appears to be in another array, and just $news['title'] does not work :(
Reply Quote
100 Draenei Shaman
11090
I got it :)
Reply Quote
90 Goblin Warlock
8825
Hey, I was looking for some thing like this however I'm not exactly sure I understand how to do this? I have a guild site and would like the news feed so i can place it in a side box.
Reply Quote
- Battle.net APIs
100 Draenei Paladin
14275
09/14/2012 06:00 AMPosted by Gëëk
I have a guild site and would like the news feed so i can place it in a side box.


what platform do you use for you site maybe i can make a mod for your site and any one else that wants it .. as long as its not joomla..
Reply Quote
100 Draenei Shaman
11090
I got this working @ www.damnationguild.net. Source Code is available @ http://sourceforge.net/p/guildnewsfeed/
Reply Quote
3 Draenei Shaman
0
09/15/2012 06:15 PMPosted by Dnul
I got this working @ www.damnationguild.net. Source Code is available @ http://sourceforge.net/p/guildnewsfeed/


nice easy script there Dnul. might use it myself one day after making it multi regional :0
Reply Quote
100 Draenei Shaman
11090
yeah, I should have kept that in mind :(
Reply Quote
- Battle.net APIs
100 Draenei Paladin
14275

$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en_US\r\n" .
"Cookie: foo=bar\r\n"
)
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file_contents = @file_get_contents($api_guild_news_url, true, $context);


then you can pass headers ... and langrage or add the http var local=en_US for example
Reply Quote
100 Draenei Shaman
11090
Any reason why json_decode would not work on the following version PHP?

Apache/2.2.22 (FreeBSD) PHP/5.3.10 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8q Server
Reply Quote
- Battle.net APIs
100 Draenei Paladin
14275
it should work make sure the file your getting contents from is not empty
Reply Quote
100 Draenei Shaman
11090
Someone is trying to utilize this in EU, and they have made all the us.battle.net to eu.battle.net changes, and the API call is returning a valid file when run manually.

I had them add the following

echo '<pre>';
print_r ($guildNews);
echo '</pre>';

And nothing was displayed.
Reply Quote
- Battle.net APIs
100 Draenei Paladin
14275
huh maybe they would rather us to curl or something lol
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Reason
Explain (256 characters max)

Reported!

[Close]