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 (10 votes, average: 4.60 out of 5)
Loading ... Loading ...
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 19 comments

  1. Gabriel Bianconi

    on May 21, 2010 at 5:28 pm

    Thank you for publishing my tutorial!

  2. Andi

    on May 29, 2010 at 1:55 pm

    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

    on June 1, 2010 at 4:42 pm

    Looking forward to trying it. Out.

  4. Vega

    on June 22, 2010 at 3:58 pm

    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

    on June 24, 2010 at 10:07 pm

    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. Integrate Mochi games in your custom arcade website | Scot Trodick's blog

    on July 16, 2010 at 3:04 am

    [...] http://www.emanueleferonato.com/2010/05/21/integrate-mochi-games-in-your-custom-arcade-website/ [...]

  7. Gil Amran

    on August 10, 2010 at 10:23 am

    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

  8. Integrate Mochi games in your custom arcade website | Team iDesign

    on August 24, 2010 at 7:09 pm

    [...] 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&quot; }); [...]

  9. jorge

    on October 27, 2010 at 6:11 pm

    Hello, this looks very useful, i´ve been looking for something like this for some time, i have a handpicked game site and i want to integrate it with mochi, but im kind of a noob, i dont have the slightest idea where to paste that code above and i cant find any support or more documentation, can anyone help out, please?

  10. ricky sanchez

    on November 2, 2010 at 11:09 pm

    Is a mochaid account free?

  11. DieselMu

    on November 12, 2010 at 1:42 am

    yes mochiads is free !

  12. connor smith

    on December 1, 2010 at 4:25 pm

    this looks great, super simple. I’ll try it out later tonight

  13. colloidal silver

    on December 12, 2010 at 6:10 am

    Seriously great! Kudos for taking the time so that you can really post consistently. I’ve been trying to as significantly as I can, but it is so difficult to get into a rhythm with blogging and site-building.

  14. Christian Robertson

    on January 23, 2011 at 5:25 pm

    Good one. I look forward to see more.

  15. Latest Phone reviews

    on February 21, 2011 at 3:41 am

    awesome, Gabriel Bianconi still 16 years old and he did a great job. thanks for script child

  16. Scott Allen

    on March 1, 2011 at 10:35 am

    Hello, I would very much like to install mochigames on my site. I’ve been told more than once that mochigames will not work on my e107 website, but I refuse to believe it. Will this script allow me to accomplish my goal and if so would you help me install it?

    Thank you very much.

  17. utility warehouse

    on April 13, 2011 at 3:39 pm

    but how to install it
    ?

  18. Noob

    on September 24, 2011 at 5:17 pm

    Please little more help, full/ tutorial for newbies like me. Where this file goes, what i need to do , i am confused. Please ???????????

  19. ???????????????????

    on October 7, 2011 at 3:18 pm

    Thanks for good tutorial