Blizzard Community Platform API

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Sylvain Lecoy's picture

Hello everyone,

I am about to release the first version of an API module used to integrate Blizzard Community Plateform API and Drupal; It need reviews and any help is appreciated.

Here is the link of the discussion: http://drupal.org/node/1351312

This module is a set of a base component and products to integrate with drupal core. The Blizzard Community Platform API enables communication with the RESTful APIs exposed through the World of Warcraft community site.

This module is only available for Drupal 7 and the first release only support Character, Guilds and Rank management. The code is tested and more work is needed to cover all the features. The module is used in production on the live demo website provided on the project page.

Here is the project page: http://drupal.org/sandbox/SylvainLecoy/1256604

Here is the git repository: http://drupalcode.org/sandbox/SylvainLecoy/1256604.git

Here is the production website: http://shinsen.fr/

Please feel free to ask any questions or make remark about the code, copy or architecture.

Sylvain Lecoy

Comments

Nice work.

cooperaj's picture

I was looking at getting something like this implemented on my site. It appears you've done a load of the grunt work already. Nice :D

I have a few points/queries though.

  1. How do I get usernames displayed throughout the site to use the attached main character as you have on your demo site forums?
  2. I had to fix the wow_character.module file with the correct menu page callback for character admin since it was referring to the old non-namespaced code.
  3. Is the code engineered in such a way as to allow 'characters' as opposed to just world of warcraft characters? We're looking at bringing in guildwars2 and SWTOR characters at some point (as well as many others conceivably)
  4. Can the character listings be styled in a more standard way. I appreciate I can override with my own theme but I would imagine the default look should fit in nicely with the default drupal theme.

Thanks
Adam

Hi cooperaj, I'm glad you

Sylvain Lecoy's picture

Hi cooperaj,

I'm glad you find it useful, and you have to know that i'm open to discussion about this module. I am also looking for co-maintainer :)

About your questions:

1 - I am actually using this function to display usernames. I don't know if it worth to put it in the base module.

<?php
/**
* Implements hook_preprocess_forum_submitted().
*
* Replace topic author by its main character if existing.
*/
function wow_character_preprocess_forum_submitted(&$variables) {
 
$characters = &drupal_static(__FUNCTION__);
 
$uid = isset($variables['topic']->uid) ? $variables['topic']->uid : 0;

  if (empty(
$characters[$uid])) {
   
$characters[$uid] = db_select('wow_characters', 'c')
      ->
fields('c')
      ->
condition('uid', $uid)
      ->
condition('is_main', TRUE)
      ->
execute()
      ->
fetch();
  }

  if (
$characters[$uid]) {
   
$character = $characters[$uid];
   
$size = array('size' => 14);
   
drupal_add_css(drupal_get_path('module', 'wow') . '/css/wow.css');
   
$variables['author'] = '<span class="icon-frame frame-14" style="">' . theme('wow_character_class', array('character' => $character) + $size) . '</span> ';
   
$variables['author'] .= theme('wow_character_name', array('character' => $character));
  }
}
?>

2 - Yes I got it too, I didn't yet pushed the code into the repository, nice catch anyway. If you want to post your in-depth review in the project application page, it would be very welcomed.

3 - I was really thinking about renaming the character entity into wow_character entity, i'm planning to do it. What do you think ?

4 - What do you mean by character listings ? In the admin panel ? Sure if there is something that is not standard, please do not hesitate to correct me, I'll fix it.

Sylvain

Here is the released project:

Sylvain Lecoy's picture

Here is the released project: http://drupal.org/project/wow

Nice work :) Congratulations

cooperaj's picture

Nice work :)

Congratulations on getting it approved. I look forward to giving it some more play time.

Preparing 2.x release

Sylvain Lecoy's picture

I am in a phase where I am writing specifications of the 2.x release. You can find more here: http://drupal.org/node/1698634.

The 2.x has started its review process as I started committing in the 7.x-2.x branch. This is mainly a release that will provide robustness. The code is unit tested, contains functional and integration tests, make use of the more complete entity API system. The entity API will be part of Drupal8 core. Among many refactoring, non-1.x API complient, there is a lot of developer experience improvement and administrative improvement.

How would you like to see the API evolve ?

The 2.x version is getting here (I started writting some serious documentation) and among improvements, most noticeables are the use of entity API, the introducing of WoW Services (daemon that periodically fetch Data Resources to ensure everything is up-to-date), and the ability for entity to auto-refresh, refresh by cron, or explicitely by code. Additionally, I have set a test infected environment so that the developments will be more robust.

How do you see that kind of service ? How fine-grained should it be configurable ? How integrated with the API it should be ?

Let me know here or contact me if you want to post feedback.

Looking forward to this but...

Guibfo's picture

after installing the module when I click the World of Warcraft link on my admin menu it's completely empty. If I go on the modules page and click config in there I can see the Data Services menu, but I don't have a blizzard API key (don't think I need one for now since I'll be only testing the module to see what I can do, right?)

And when I try to use the realm services I get a Fatal error: Call to undefined method DateTime::getTimestamp() in /public_html/sites/all/modules/wow/wow.module on line 180

Sorry if this isn't the right place to post this, didn't know if I should post here or open an issue

Hello Guibfo, thank you for

Sylvain Lecoy's picture

Hello Guibfo, thank you for reporting this..!

So the World of Warcraft link is empty, just because it serves as a placeholder for other modules: characters, epgp, etc. I may add a text or something in the future because I admit this is somewhat confusing at first sight.

If you test the module, you effectively don't need yet an API key, so you're right.

I havn't tested the module on php 5.2, when you get the fatal error its calling a function which are not existing on your setup; If you want a quick fix just replace l.180 the $date->getTimeStamp() by $date->format('U'), should fix the issue.

Is php 5.2 is a requirement for you ? Would you like me to open an issue then I made the module compatible with php 5.2 or you plan to upgrade so I add php 5.3 as a new dependency for the module ?

Cheers,

Sylvain

I created two separates

Sylvain Lecoy's picture

I created two separates issues:

You can comment on here and also I encourage you to contribute for the PHP5.2 issue, it would be welcomed :)

A few more errors!

Guibfo's picture

Ok, I'm starting to think I shouldn't be using this module, not only I know very little php, but also I have no idea how to work with the API, and apparently it doesn't do what I actually wanted to do with it. I wanted to use for a community site, where any registered and identified Guild master could set his guild and be responsible for recruitment threads and some other things.

Anyway, I have a few more errors when setting the characters

Warning: reset() [function.reset]: Passed variable is not an array or object on wow_api_locale() (line 236 de public_html/sites/all/modules/wow/wow.module).

Warning: Invalid argument supplied for foreach() on wow_data() (line 268 de public_html/sites/all/modules/wow/wow.module).

Both those errors show when I click on a character after adding him to my user account (the 2 errors occurs twice every time in case that means anything)

And then these errors occurs when I try to unblock the character

Warning: reset() [function.reset]: Passed variable is not an array or object em wow_api_locale() (linha 236 de /home/letsr059/public_html/sites/all/modules/wow/wow.module).
Warning: Invalid argument supplied for foreach() em wow_data() (linha 268 de /home/letsr059/public_html/sites/all/modules/wow/wow.module).
Warning: reset() [function.reset]: Passed variable is not an array or object em wow_api_locale() (linha 236 de /home/letsr059/public_html/sites/all/modules/wow/wow.module).
Warning: Invalid argument supplied for foreach() em wow_data() (linha 268 de /home/letsr059/public_html/sites/all/modules/wow/wow.module).
Notice: Trying to get property of non-object em wow_character_user_unblock() (linha 301 de /home/letsr059/public_html/sites/all/modules/wow/modules/wow_character/wow_character.pages.inc).
Notice: Trying to get property of non-object em wow_character_user_unblock() (linha 304 de /home/letsr059/public_html/sites/all/modules/wow/modules/wow_character/wow_character.pages.inc).
Notice: Trying to get property of non-object em wow_character_user_unblock() (linha 301 de /home/letsr059/public_html/sites/all/modules/wow/modules/wow_character/wow_character.pages.inc).
Notice: Trying to get property of non-object em wow_character_user_unblock() (linha 304 de /home/letsr059/public_html/sites/all/modules/wow/modules/wow_character/wow_character.pages.inc).
Notice: Trying to get property of non-object em wow_character_user_unblock() (linha 301 de /home/letsr059/public_html/sites/all/modules/wow/modules/wow_character/wow_character.pages.inc).
Notice: Trying to get property of non-object em wow_character_user_unblock() (linha 304 de /home/letsr059/public_html/sites/all/modules/wow/modules/wow_character/wow_character.pages.inc).
Notice: Trying to get property of non-object em wow_character_user_unblock() (linha 301 de /home/letsr059/public_html/sites/all/modules/wow/modules/wow_character/wow_character.pages.inc).
Notice: Trying to get property of non-object em wow_character_user_unblock() (linha 304 de /home/letsr059/public_html/sites/all/modules/wow/modules/wow_character/wow_character.pages.inc).

It still shows me the instructions for unblocking it below the errors, and I can even manage to unblock it, but it still shows me the first errors when I try to click on the character name (the http://example.com/character/us/server/character link)

Ok thanks again for your

Sylvain Lecoy's picture

Ok thanks again for your feedback.

I think for the objectives you have this module perfectly fit with. Although there is some non-friendly errors attacking you while testing it is something that I may have not tested well before releasing. That's why user feedback is essential to make quality software.

About the API itself, you may want to have a look at wow_guild_fetch functions and the wow_realm form API selectoe. What is your level in php ? How much do you know about drupal ?

Sylvain

As I said, I know very little

Guibfo's picture

As I said, I know very little about php, and drupal too, I started with both 4 months ago on my Internship. I can do some minor tweaks on drupal with php, but to be honest I don't know how to rate my level on php, I can understand a lot of it but I can't reproduce it myself (only some basic stuff), and I still get confused with some structures, so whenever someone asks I rather say I'm a total noob, even though I'm not completely lost in the dark. And about Drupal, before having to fix those few lines I never opened any module files, just some tweaks on the basic templates files, I'm only familiar with the non-programming part of it.

When I said this module probably isn't for me is because even though I realize that the blizzard API would give me the resources I need for the type of website I'm planning (a community website, not a "my guild" website), I have no clue where to start, specially if it means writing a drupal module (or part of it at least)

If you don't know a lot about

Sylvain Lecoy's picture

If you don't know a lot about drupal and php I would not suggest you to use the blizzard API module, which is a pure wrapper of the service. That mean you will have to write a lot of code for storing and sorting your data.

The thing is, you can perfrectly use the wow API module to make a community website and not a "My guild" website. It is not because you have the possibility to have a default guild that you must use it. This functionality is intended for people who are using the guikd rank module and epgp module. That's a possible use of the API but that does not mean you have to actually use it.

The best thing is that you email me via my contact form then I will be able to help you more in details.

Sylvain