Kevin Fell

Development Journal

Xbox 360 Gamercard Plugin for WordPress

Update 06.05.2011:Version 1.51 is available, this brings the plugin inline with the latest Xbox live gamercard update, please download the latest version here.

The Xbox 360 Gamercard plugin for WordPress allows you to display one or more Xbox gamercards anywhere on your WordPress website.

Until now, the latest version of this plugin, originally written by Oliver Baty, was broken after the recent updates to the Xbox Live gamercard service. I initially rewrote Oliver’s plugin to bring it inline with the recent service updates allowing me to use it on my own WordPress website, by providing this update as a download I hope others can also put this to good use.

How do I install it?

  1. Backup your existing installation if present, taking a copy of the ‘gamercard-plugin’ directory is sufficient.
  2. Download the Xbox 360 Gamercard Plugin for WordPress.
  3. Login to your WordPress administration user interface.
  4. Click “Plugins” from the menu on the left, then click “Add New” followed by “Upload”.
  5. Browse to the zip file you downloaded in step 2.
  6. Activate the Xbox 360 Gamercard Plugin from your WordPress plugins menu.

How you I use it?

Just drag and drop the “Xbox 360 Gamercard” widget into your dynamic sidebar from the WordPress administration user interface and enter your gamertag.

Should you wish to add the gamercard to another area of your website or your theme doesn’t support the dynamic sidebars, just add the following line of code where you’d like the gamercard to appear:

<?php if (function_exists('gamercard')) gamercard('YOURTAG'); ?>

Just remember to replace YOURTAG with the gamertag you wish to show and don’t forget to enable the Xbox 360 Gamercard plugin for WordPress to show the gamercard on your site.

You can alter the stylesheet to customise the plugin, should you wish to alter the HTML, search for the ‘gamercard_toHTML’ function in xbox-gamercard.php script.

So Whats Changed?

To keep things simple, you no longer have to copy the stylesheet and ‘gc_images’ folder into your chosen theme, they sit in the plugin’s directory and the plugin takes care of everything for you.

The parsing routing has been rewritten to support the latest gamercard service response.

The Xbox 360 Gamercard plugin will, by default, cache your avatar and the recent game history images by combining them into single png sprite. This reduces the number of DNS look ups by 1 and the number of HTTP requests required to render your website by upto 5, this in turn reduces network traffic, reduces bandwidth usage and improves speeds. This feature adheres to the Yahoo! rules for high performance web pages and will improve your websites YSlow score when compared to the previous version. Basically, its one less thing for the perfectionists to worry about.

This plugin now caches the gamercard as a html, its disabled by default and, if I’m honest, I wouldn’t waste your time enabling it. There are several WordPress plugins, for example WP Super Cache, which do a fantastic job of managing your entire websites cache, any kind of caching tool would have rendered the affects of this feature useless anyway.

Version 1.5 of the Xbox 360 Gamercard for WordPress introduced additional features including WordPress widget support, support for non-WordPress websites and SSL friendly content. You can read more on these updates on this blog post.

Anything else?

Nope, that’s it! I welcome any comments or suggestions you have. Feedback, positive or negative, will always be considered.





About the author

Kevin Fell
Kevin Fell is a professional web developer, indie programmer and die hard gamer specialising in C, C++, PHP, SQL, XHTML, CSS, JavaScript and jQuery.



43 Comments for Xbox 360 Gamercard Plugin for WordPress
kimatg

Awesome, but could you release a standalone version of the plugin for non-wordpress users as well? I’d be really thankful if you did. T_T

Kevin Fell

Hi Kimatg,

Thank you for your feedback, I have almost finished an update which will allow you to run the same script on both WordPress and non-WordPress websites. I should have it finalised within the next few days.

- Kevin.

velocity7

Hello Kevin, great job with the widgetized version of this plugin and getting it to work well. However, I do notice that Japanese names do not show up properly with the plugin (see my blog). Will a fix be forthcoming?

Kevin Fell

Hi velocity7,

Thanks for your comments. The issue your experiencing is to do with the page encoding rather than the plugin itself. I notice your site has the required utf-8 encoding so it could be your sites cache?

Try temporarily disabling the cache feature on the plugin and any other caching you have enabled on your site.

The Japanese text appeared fine when I tested your gamercard both as a WordPress widget and on a non-WordPress site.

- Kevin.

velocity7

Hey again Kevin,

Turning off caching on the plugin didn’t seem to have any positive effect. I don’t have any other caching on my blog either, so I’m not sure what the issue might be.

Kevin Fell

Hey,

I have the plugin working for your gamercard in a test environment. I’ll take a look at your sites html and the gamercard output to see if I can find the problem. I’m confident I can find a solution for you :)

- Kevin.

velocity7

Did you ever find a solution, Kevin? :)

TheArtofBalance

Hey Kevin, Your plugin is great and I’m glad someone decided to step up and take it over. This might be too much to ask but, is there, or will there, be any way to use this plugin with WordPress users or Buddypress? It would be great to have the widget display the Gamer-tag of the user who is logged in. Ive tried using a bit of php and some of Buddypress’s x-profile fields to get the job done but so far I’m stumped.

Kevin Fell

Hey,

Thanks for your comments, a feature to show gamercards for logged in users is a great idea. I’ll look into this next time I work on the plugin.

Due to time constraints and other project commitments, I have no intention to explore BuddyPress at this time.

- Kevin.

TheArtofBalance

Hey Kevin,

After a bit of tinkering around and some guidance, I was able to tie your plugin into Buddypress and achieve my desired results. Thanks again for an awesome plugin. I’m looking forward to future updates.

Rick

I tried to put up the gamercard on the widget and it ends up causing a break in the code execution and nothing and comes up but yet it never throws and error. Am I missing something??

Kevin Fell

Hi Rick,

What version of WordPress are you using and whats your gamercard name?

- Kevin.

Justin Schuhmann

Hey Kevin,
I was curious if online status and add as friend links could also be added?

Kevin Fell

Hi Justin,

Its a good suggestion, I’ll keep this in mind when I next work on the plugin.

- Kevin.

Reece

It won’t work for me have a look here http://phptest.site90.net/non-wp-example.php and my mate has tryed it with wordpress but its still the same :( help

Kevin Fell

Hi Reece,

I suspect the script didn’t get a valid response from the xbox live gamercard services. I noticed there is nothing in the script to catch this condition which explains your results and so I will need to update accordingly.

I will email you once this has been resolved.

- Kevin.

Reece

Ok thanks Kevin

Kevin Fell

Hi Reece,

I’ve updated the plugin which will resolve this issue for you. Microsoft changed the xbox gamercard feed which broke the plugin.

You’ll find the download links at the top of this blog entry, enjoy :)

- Kevin.

Jay

Hi Kevin

there is a way to make it working in php4?

i just got “Warning: domdocument() expects at least 1 parameter, 0 given in”
and “Fatal error: Call to undefined function: loadhtml() in ” errors

thanks

Kevin Fell

Hi Jay,

Try changing line 399 in gamercard-plugin.php from:

$html = new DOMDocument();

to:

$html = new DOMDocument(1.0, 'UTF-8');

I dont have php4 installed so I couldn’t tell you if this would work or not but this would supply the DomDocument() function with the parameters it requires for your version of php.

PHP4 is end of life so its in everyone’s best interest to upgrade to a newer, supported version.

- Kevin.

Reece

Hello Kevin i was thinking can you make it so its a image gamercard? so you can use it as a image on forums

Kevin Fell

Hi Reece,

Its definitely something I could do. I’ll keep the idea for when I next work on the plugin.

- Kevin.

Jay

looking for this too,will be an really cool add-on.

Thanks again Kevin

Paul Large

Hey buddy just tried installing this and I’m getting;
Fatal error: Call to undefined function curl_init() in C:\xampp\xampp\htdocs\wordpress\wp-content\plugins\gamercard-plugin\xbox-gamercard.php on line 329

Any ideas?

Kevin Fell

Hi Paul,

Curl is a PHP extension. When the function is undefined it means its not loaded on your web server.

Locate your php.ini file on your web server and then locate the following line:

#extension=php_curl.dll

You’ll need to uncomment the line by removing the hash character. Once done, save your changes and restart your web server.

If the Curl extension is missing altogether you’ll need to reinstall PHP and ensure you mark the Curl extension for installation.

- Kevin.

Dennis

Hi Kevin,
is it possible to add the gamercard with it’s full functionality into a normal wordpress blog post? If yes, could you please tell how to do it?

Thanks in advance

Dennis

Kevin Fell

Hi Dennis,

You cannot place php into a blog post, this means it wouldn’t be possible without editing your theme.

- Kevin.

Ashish

Why dont you place this into WordPress Plugin Repository. The plugin has a chance to do lot well and people can even trust more.

Kevin Fell

Hi Ashish,

Thanks for the kind words. I’ve signed up to the WordPress repo, I hope to move everything across in the coming weeks.

- Kevin.

Eric

Hey, awesome work… so glad that somebody was willing to take this on. Are there any forums set up for this? I’m hitting an error with multiple tags. I got one tag working fine, but as soon as I add any others:

Fatal error: Call to a member function getAttribute() on a non-object in /home/dentedca/public_html/wp-content/plugins/gamercard-plugin/xbox-gamercard.php on line 469

This happens both in widget area as well as called php. Thanks in advance for any insight you could provide :D

Kevin Fell

Hi Eric,

Thanks for your kind words. This should be retentively simple to fix and I will check it out when I get a spare moment.

- Kevin.

JC

Hi, your plug-in is great. I was just wondering is there anyway I could show my actual wins / losses from like madden or any other game?

thanks.

Eric

HEADS UP!!

The new Xbox dashboard update (of December… 9th?) added some extra stuff to the games list, and it’s not working with the plugin! For me it’s just Netflix and Zune video, and xbox-gamercard.php is throwing errors for “$gameTag->getAttribute(‘href’)”, “foreach()”, “getimagesize()”, “foreach()”, and “getimagesize()” on lines 469, 472, 502, 472, and 502 respectively.

Will try and post again when I get some error handling in there.

Eric

Added a test to see if gameTag exsited: if($gameTag){

Apologies for my terrible php, I’m sure there’s a better way to test that. Updated function can be found at http://pastebin.com/J3AqMbAm

Eric

Incidentally, that should also fix my previous problem with line 469 as well.

West McGowan

Eric, you’re a life saver =]

Kevin Fell

Hi Eric,

The plugin supports the latest live service update. The error you point out is caused by gamertags which have less than 5 recently played games.

There is a check in the script for this scenario but after looking at your issue its not catching it. Your solution does fix the problem, the follow change however is the best fix for the issue:

Change line 463 from:
if (!count($gameTag))

to:
if ($gameTag->length == 0)

- Kevin.

Urabe

I’m a foreigner. English is not good at.
How can I display an gameicon Youtube and Hulu? (like the xbox360)
…or Can I remove the space Hulu & Youtube icon?
This plugin is great.

Kevin Fell

Hi Guys,

I’m currently testing an update for this plugin, the new version can be seen in the sidebar on this website. As always, your comments and suggestions are welcome.

- Kevin.

Eric

Slick dude… some rollovers would be awesome, maybe with a bigger game image or some stats, not totally sure what info is passed to the plugin. MagicZoom maybe?

Definitely need to include the old version (or something more horizontal) though, our site needs it like that ;)

Kevin Fell

Hi Eric,

I agree I’ll need something more horizontal as well. There are some additional stats and images available, I’ll play around with the rollovers idea and see what I can come up with.

- Kevin.

Jeff

HI,

The plug-in does not seem to work with WordPress 3.3 at all, in case it is still developed. If not guess will need to find an alternative :(

Kevin Fell

Hi Jeff,

It does work with WordPress 3.3. Please let me know your gamertag and I’ll investigate what’s causing the issue.

I’m currently testing a new version of the plugin which should be ready by the end of the month.

- Kevin.




Leave a comment





 

© Kevin Fell 2012