Winter!: Prepare for holiday gaming!

Forums top   gamerDNA.com Forums > gamerDNA.com > Helix Developers/API (Beta)

Thread Tools
Old 12-16-2008, 01:39 AM
squidpunch's Avatar
squidpunch squidpunch is offline
Join Date: Mar 2008
Location: Pennsylvania
Posts: 19
squidpunch has much to be proud of
C# API Bridge
So I started toying around with building a C# library that could be used in any of the VB.NET or C# to interact with the GamerDNA API's - partially just play around with C# a bit more, and partially for ease of use for the APIs.

In reality to access and consume a remote XML API isn't that difficult to do in C# but this would take even more of the complexity out of it.

So anyone actually interested in using the APIs looking to cut some of your development time? Let me know I might actually release it for download - if I finish all the APIs

Just to give you an idea here is a very basic C# sample using my DLL, it might not be the most real world example but it works.

protected void Page_Load(object sender, EventArgs e) { GamerDNA.API.Group.GetRoster api_call; api_call = new GamerDNA.API.Group.GetRoster("gamerdna-war", YOUR_API_KEY); Response.Write("<H2>" + api_call.guild_name + "</H2>"); foreach (GamerDNA.DataTypes.RosterMember member in api_call.members) { Response.Write(member.member + "<br>"); } }
which would look something like this - the guild name in a bigger heading and listing all the members - all the other data elements from the api would be available just not displayed in this sample



now if you were to do the same thing - and only pull the data displayed in the above example it would look something like this

protected void Page_Load(object sender, EventArgs e) { System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); Encoding enc = Encoding.GetEncoding("utf-8"); string url; url = "http://helix.gamerdna.com"; url += "/get_guild_roster.php"; url += "?guildname=gamerdna-war"; url += "&apikey=YOUR_API_KEY"; Uri uri = new Uri(url); System.Net.WebRequest request = System.Net.WebRequest.Create(uri); System.Net.WebResponse response = request.GetResponse(); System.IO.Stream stream = response.GetResponseStream(); System.IO.StreamReader reader = new System.IO.StreamReader(stream, enc); string data = reader.ReadToEnd(); xmlDoc.LoadXml(data); System.Xml.XmlNodeList nodes = xmlDoc.SelectNodes("api/profile/guildname"); if (nodes.Count > 0) { System.Xml.XmlNode node = nodes[0]; Response.Write("<h2>" + node.InnerText + "</h2>"); } System.Xml.XmlNodeList member_nodes; member_nodes = xmlDoc.SelectNodes("api/profile/members/memberProfile"); if (member_nodes.Count > 0) { foreach (System.Xml.XmlNode node in member_nodes) { foreach (System.Xml.XmlNode member_node in node.ChildNodes) { if (member_node.Name == "member") { Response.Write(member_node.InnerText + "<BR>"); continue; } } } } }
this would only pull the data elements shown in the above output (guild name, and each member name) you would have to further expand the XML reading to get the rest of the information in the API, and rebuild this similar functionality for the other APIs.

I might do something similar in PHP if that's more agreeable to other API developers, but wanted to dust off some C# skills.
Reply With Quote
Old 12-16-2008, 07:38 AM
doxxan's Avatar
doxxan doxxan is offline
Join Date: Oct 2007
Location: Sweden
Posts: 87
doxxan is community member of note
Interesting. Might just dust off my old C# skills for this.

"What is darkness? It doesn't exist where there's light, and without light, it's nothing..."
Reply With Quote
Old 02-17-2009, 10:10 PM
Epikhigh Epikhigh is offline
Join Date: Feb 2009
Posts: 1
Epikhigh has much to be proud of
I would be extremely interested in this.
Reply With Quote
Post Reply

Thread Tools

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