ManiaHome.NET, the ASP.NET ManiaHome Library (Version 1.1)

Discuss all the publishing tools, including ManiaHome, ManiaPub, ManiaFlash and ManiaPress in this forum

Moderator: NADEO

Post Reply
User avatar
fastforza
Posts: 859
Joined: 15 Jun 2010, 11:19
Contact:

ManiaHome.NET, the ASP.NET ManiaHome Library (Version 1.1)

Post by fastforza »

Introducing ManiaHome.NET, the ASP.NET ManiaHome library.

As stated by me somewhere, I've released an ASP.NET version of the ManiaHome library. The library is free, open source, lightweight and extremely easy to use. 8-)

ManiaHome.NET operates in the exact same manner the PHP library operates. It allows you to post notifications to ManiaHome, the ingame social network provided by Nadeo. Additionally it operates only for the ASP.NET framework, making it possible for ASP.NET developers to take advantage of the API with this easy to use library.

Visit the ManiaHome.NET project page today! Project page contains further information, step by step documentation, code samples and the source code. Suggestions and contributions are welcome! :ugeek:

ManiaHome.NET Requirements
- ASP.NET Framework 4.0

ManiaHome.NET Instructions
- You must follow steps 2 and 3 in this thread!
- Other instructions can be found on the project page.

Looking for the PHP ManiaHome library? Click Here!

TMF Only! May not work with ManiaPlanet!
Last edited by fastforza on 12 Oct 2011, 08:32, edited 2 times in total.
Mania Exchange - Share your maps!

ASUS Maximus IV GENE Z / i7 2600K 3.40Ghz QC / 16GB G.Skill Ripjaws DDR3 / GTX 560 Ti

Need technical help for ManiaPlanet? Click here. :)
User avatar
gouxim
Nadeo
Nadeo
Posts: 1188
Joined: 14 Jun 2010, 17:20

Re: ManiaHome.NET

Post by gouxim »

That's great, good job!

I was going to ask if you can change the user agent, but I just saw the TODO in the source code :) It doesn't change anything about the way it works, but it gives us information (in the apache logs, and then in our statistics) about what clients are interacting with the API.

edit: oh and I edited the topic title
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
fastforza
Posts: 859
Joined: 15 Jun 2010, 11:19
Contact:

Re: ManiaHome.NET, the ASP.NET ManiaHome library

Post by fastforza »

Thanks. 8-)

In the next release (or whatever I'll do), I'll change the user agent string and I'll add style support.

@title: That's ok, looks better. :P

Any future API's, you should keep me informed, might be able to make ASP.NET versions. :mrgreen:
Mania Exchange - Share your maps!

ASUS Maximus IV GENE Z / i7 2600K 3.40Ghz QC / 16GB G.Skill Ripjaws DDR3 / GTX 560 Ti

Need technical help for ManiaPlanet? Click here. :)
User avatar
gouxim
Nadeo
Nadeo
Posts: 1188
Joined: 14 Jun 2010, 17:20

Re: ManiaHome.NET, the ASP.NET ManiaHome library

Post by gouxim »

Actually, what you might want to do to save time is what we just did with ManiaLib.

On the one hand, we have our generic REST client.

http://code.google.com/p/manialib/sourc ... Client.php

You'll want to take a look at the execute() method. Basically you specify:

* The HTTP method: GET, POST, PUT or DELETE
* The ressource
* The parameters

The simpliest way would to treat the 3rd parameter as data to put in the request body (for POST and PUT).

But here, what we did is the ressource is treated as a string for sprintf(), parameters beeing taken from the array given as 3rd param of the execute method. Let's look at at a few example:

Code: Select all

$client->execute('GET', '/foobar/'); => GET /foobar/
$client->execute('GET', '/foobar/%s'/', array(1337)); => GET /foobar/1337/
$client->execute('POST', '/foobar/%s/', array(1337, some_object)); => POST /foobar/1337/ with "some_object" in the request body
On the other hand, we have the ManiaHome client for ManiaLib which is built on top of the Rest Client. As you can see the code is very simple:

http://code.google.com/p/manialib/sourc ... Client.php
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
gouxim
Nadeo
Nadeo
Posts: 1188
Joined: 14 Jun 2010, 17:20

Re: ManiaHome.NET, the ASP.NET ManiaHome library

Post by gouxim »

It's also woth mentioning that the data type that you put in the request body doesn't really matter, as long as the key matches. In my library I created an array because it's very simple in PHP. But I could also have created an object.

For example posting:

Code: Select all

array( "key" => "value")
and:

Code: Select all

$object = new stdClass();
$object->key = "value";
are the same when you POST the request. The reason is that the json_encode function in PHP treats array with non-numeric keys as objects, so in the end the serialized string that is put in the body of the POST request is the same:

Code: Select all

{"key":"value"}
So the bottom line is: if it's simplier for you to create objects instead of arrays when you POST data on the API, go and do that :)
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
fastforza
Posts: 859
Joined: 15 Jun 2010, 11:19
Contact:

Re: ManiaHome.NET, the ASP.NET ManiaHome library

Post by fastforza »

I'll get around to creating a standalone REST client for the API soon. Seems acceptable if you introduce more API's and I create more ASP.NET versions. Time saver too, guess I never thought about it. :P

In PHP, arrays are handled far differently from ASP.NET

Code: Select all

array( "key" => "value") 
PHP arrays can have keyvaluepairs, while ASP.NET cannot (indexes and values only), instead you have collections

Code: Select all

Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("key", "anyObjectHere");
That's why you see a collection Dictionary<TKey, TValue> being specified as the data parameter.

When serialized with the JavaScriptSerializer the output will of course, be the same. :P

Code: Select all

{"key":"anyObjecthere"}
It's not so much a matter of it being simpler or different, it's a matter of it being the only way to pass a collection of keys and values.

Update: I've started a new project and all the namespaces have changed. I'll Keep ManiaHome as is, perhaps an optional download in the future.
Last edited by fastforza on 22 Apr 2011, 14:14, edited 1 time in total.
Mania Exchange - Share your maps!

ASUS Maximus IV GENE Z / i7 2600K 3.40Ghz QC / 16GB G.Skill Ripjaws DDR3 / GTX 560 Ti

Need technical help for ManiaPlanet? Click here. :)
User avatar
gouxim
Nadeo
Nadeo
Posts: 1188
Joined: 14 Jun 2010, 17:20

Re: ManiaHome.NET, the ASP.NET ManiaHome library

Post by gouxim »

That's nice. Note that REST architecture is the one used on Facebook's and twitter's APIs (and many others), so you might find some useful ASP.net code in the SDKs of those services.
Please do not PM for support. Instead, create a thread so that everyone can contribute or benefit from the answer! 8-)
User avatar
fastforza
Posts: 859
Joined: 15 Jun 2010, 11:19
Contact:

Re: ManiaHome.NET, the ASP.NET ManiaHome library

Post by fastforza »

Hmm I might take look if I get a chance.
Mania Exchange - Share your maps!

ASUS Maximus IV GENE Z / i7 2600K 3.40Ghz QC / 16GB G.Skill Ripjaws DDR3 / GTX 560 Ti

Need technical help for ManiaPlanet? Click here. :)
User avatar
fastforza
Posts: 859
Joined: 15 Jun 2010, 11:19
Contact:

Re: ManiaHome.NET, the ASP.NET ManiaHome library

Post by fastforza »

I've released ManiaHome.NET 1.1. :D

Changes Include
- Ability to specify ManiaLink styles.
- The client now sends a new user agent string: ManiaHome ASP.NET Library

Enjoy. :mrgreen:
Mania Exchange - Share your maps!

ASUS Maximus IV GENE Z / i7 2600K 3.40Ghz QC / 16GB G.Skill Ripjaws DDR3 / GTX 560 Ti

Need technical help for ManiaPlanet? Click here. :)
Post Reply

Return to “Ingame Publishing”

Who is online

Users browsing this forum: No registered users and 3 guests