Integrate Mochi games in your custom arcade website

Do you want to create your custom arcade website without using popular arcade scripts or WordPress plugins? Maybe with a Mochi integration?

That’s what Gabriel Bianconi did, and he wants to share his script with us.

It’s a simple, interesting script dedicated to all developers looking for a quick way to integrate Mochi games into their custom arcade sites.

« Hello. My name is Gabriel Bianconi. I’m a 16 years old Brazilian student and I’m interested in game and web development.
I’ve recently launched my first arcade website, PlugB.com. I decided to create my own script for two reasons: to improve my PHP skills and to have a more customizable website.

One of the features I integrated to my admin was the MochiAds ‘Post Game to my Site’ button. Since I add games manually (I don’t want to import all Mochi games), this saves me a lot of time.

When I tried to search about this feature, I realized that there is no tutorial about this online (at least, I couldn’t find one). I searched a little more and found a few scripts about this.

They were integrated to some arcade scripts, so I couldn’t just copy and paste them. But it was a start.

The script that I most used was from Timothy E. Archer.

After a few tests, I’ve created a working script:

Firstly, you’ll need a MochiAds publisher account.

After registering and adding your website, go to the Settings page.

In the bottom of the page, below ‘Auto Post Settings’, set the ‘Auto Post Method’ to ‘Custom built script’ and the ‘Auto Post URL’ to the URL of your script.

Now the PHP part:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
 
$game_tag = $_POST['game_tag'];
 
// Sample tag to fake a mochi request... Remove this line in final version...
$game_tag = 'cd698a06f727e887';
 
if(!$game_tag)
{
	die('No gametag.');
}
 
// This can be found in the settings page.
$mochi_pub_id = 'xxxxxxxxxxxxxxxxxxxxx';
 
$game_feed_url = "http://www.mochiads.com/feeds/games/$mochi_pub_id/$game_tag/?format=json";
 
//Retrieves and parses the JSON data of the game.	
$json_feed = file_get_contents($game_feed_url);
$json_items = json_decode($json_feed, TRUE);
 
$game = $json_items['games'][0];
 
/* Now you can access all variables about the game with $game['variable_name'];
 * For example: $game['name'] or $game['swf_url']
 * The full list of the variables can be found here: https://www.mochimedia.com/support/pub_docs#feed_3
 * I did not add how to save in a database because it changes from script to script.
 */
 
 
// Sample: (can be removed in final version)
 
echo $game['name'] . ' - ' . $game['swf_url'];
 
/* You should get: Sokobones - http://games.mochiads.com/c/g/sokobones_v1/Sokobones-MochiAds_Secure.swf
 * if you used the sample tag.
 * Remove that line in the final version.
 */
 
?>

Remember to remove the sample game tag in the final version.

Thank you for reading the tutorial. I hope this helps you. Please let me know what you think about this and visit my arcade website. »

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.00 out of 5)
Loading ... Loading ...
If you found this post useful, please consider a small donation.

8 Responses

  1. Thank you for publishing my tutorial!

  2. Andi says:

    You can find the complete code for wordpress integration and some explanations here: http://blog.creative-webdesign.info/2010/05/29/autopost-mochiads-games-in-your-wordpress-arcade-website.html

  3. HoodaMath says:

    Looking forward to trying it. Out.

  4. Vega says:

    thx Gabriel for this very usefull snippet and ofc Emanuele for posting it :)

    Now i just need to implement some quality-threshold to decide which games i can “ignore”. *thinking*

  5. Azarai says:

    The integration with mochiads is easy , the hard part is running the site successfully :-)

    btw i did code an arcade site with python some time ago, maybe it useful for your readers
    http://codeboje.de/flash-game-portal-python/

  6. Gil Amran says:

    Hi,
    I know that it’s not totally related, but I didn’t find other way to contact you…
    My question is very simple:
    I’m a AS3/Flash developer with a very long background in programming, and I thought about moving into the Android arena…. I’ve read many of your posts, and it seems that you know what you’re doing.

    On one of your posts you mentioned that in Italy a developer get ~$44 per hour. and you wanted to a get a game to give you $123 per hour… you didn’t say if it worked…

    so the question is, does it worth it? is the money good?

    Thanks
    Gil

  7. [...] http://www.emanueleferonato.com/2010/05/21/integrate-mochi-games-in-your-custom-arcade-website/ SHARETHIS.addEntry({ title: "Integrate Mochi games in your custom arcade website", url: "http://www.teamidesign.com/?p=28" }); [...]

Leave a Reply