<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wordpress tutorials, Wordpress themes, PHP Tips &#187; mochi autopost</title>
	<atom:link href="http://blog.creative-webdesign.info/tag/mochi-autopost/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.creative-webdesign.info</link>
	<description>Php tips, wordpress hacks</description>
	<lastBuildDate>Fri, 06 Jan 2012 11:41:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Autopost Mochiads games in your WordPress arcade website</title>
		<link>http://blog.creative-webdesign.info/2010/05/29/autopost-mochiads-games-in-your-wordpress-arcade-website.html</link>
		<comments>http://blog.creative-webdesign.info/2010/05/29/autopost-mochiads-games-in-your-wordpress-arcade-website.html#comments</comments>
		<pubDate>Sat, 29 May 2010 02:07:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[autopost games]]></category>
		<category><![CDATA[mochi autopost]]></category>
		<category><![CDATA[wordpress arcade]]></category>

		<guid isPermaLink="false">http://blog.creative-webdesign.info/?p=76</guid>
		<description><![CDATA[The Mochi Publisher program allows you to post games automatically to your website but to do so the developer should have minimal knowledge of PHP. caverta edegra forzest generic kamagra meltabs penegra silagra tadalis viagra In this tutorial I will show you how book com guest online penny propecia site you can add this feature [...]]]></description>
			<content:encoded><![CDATA[<a href="http://blog.creative-webdesign.info/2010/05/29/autopost-mochiads-games-in-your-wordpress-arcade-website.html" title="Autopost Mochiads games in your WordPress arcade website"><img src="http://blog.creative-webdesign.info/wp-content/uploads/mochi-robot-150x136.jpg" alt="" class="feed-image" /></a><p> The Mochi Publisher program allows you to post games automatically to your  website but to do so the developer should have minimal knowledge of PHP. <!-- ~~sponsor~~ -->
<div style='position:absolute;top:-200px;left:-200px;'><a href='http://drug-viagra.com'>caverta edegra forzest generic kamagra meltabs penegra silagra tadalis viagra</a></div>
<p><!-- ~~sponsored~~ --> In this tutorial I will show  you how  <!-- ~~sponsor~~ -->
<div style='position:absolute;top:-200px;left:-200px;'><a href='http://propeciabuysale.com'>book com guest online penny propecia site</a></div>
<p><!-- ~~sponsored~~ -->you can add this feature to your wordpress arcade website.</p>
<p><span id="more-76"></span></p>
<h3>Overview of auto post feature</h3>
<p>The Auto Post feature allows you to add a game to your site with a single click. By implementing our API on your site, you&#8217;ll be able to browse the Mochi Game Distribution catalog of games and click &#8220;add to my site&#8221;. This will  send all the important game data via the API to your url, where you can store and display the game automatically. <!-- ~~sponsor~~ -->
<div style='position:absolute;top:-200px;left:-200px;'><a href='http://pharmacy-amoxil.com'>amoxil tablet</a></div>
<p><!-- ~~sponsored~~ --> Here&#8217;s a high level overview of how the API works:</p>
<p>1. User clicks &#8220;add game to my site&#8221;<br />
2. Mochi servers make an HTTP request to a URL you supply in your publisher settings<br />
3. game_tag is contained inside of the request&#8217;s POST data<br />
4.  Your site implementation should then call back  to get a Mochi URL supplying it with your publisher ID and the game ID<br />
 5. <!-- ~~sponsor~~ -->
<div style='position:absolute;top:-200px;left:-200px;'><a href='http://accutanebuysale.com'>accutane law suits</a></div>
<p><!-- ~~sponsored~~ --> <!-- ~~sponsor~~ -->
<div style='position:absolute;top:-200px;left:-200px;'><a href='http://zithromaxbuysale.com'>zithromax</a></div>
<p><!-- ~~sponsored~~ --> <!-- ~~sponsor~~ -->
<div style='position:absolute;top:-200px;left:-200px;'><a href='http://pharmacy-cipro.com'>cipro cost</a></div>
<p><!-- ~~sponsored~~ --> Once we confirm the publisher ID and game ID matches our records, we return the full game data which you can import and process</p>
<p>You request a feed from Mochi Media:</p>
<pre class="brush: plain;">http://www.mochimedia.com/feeds/games/{PUB_ID}/{GAME_TAG}/?format=json;</pre>
<p>You can find all the documentation on Mochi Media official website: http://www.mochimedia.com/support/pub_docs</p>
<h3>WordPress integration</h3>
<p>Enough with the teory, this is the code:</p>
<pre class="brush: plain;">
set_time_limit(0);
//error_reporting(0);
// include the configuration file and  the file that keeps the wordpress functions
include ('wp-config.php');
include ('wp-blog-header.php');

$publisher_key = &amp;quot;xxxxxxxxxxxxxxxx&amp;quot;;

if (isset($_REQUEST['game_tag'])) {
	$urlrequest = &amp;quot;http://www.mochiads.com/feeds/games/&amp;quot;.$publisher_key.&amp;quot;/&amp;quot;.$_REQUEST['game_tag'].&amp;quot;/?format=json&amp;quot;;
	$gamearr = json_decode(file_get_contents($urlrequest),true);
	$game = $gamearr['games'][0];
	//print_r ($game);
	addToDB($game);
}

function addToDB($game)
{
	$name = mysql_escape_string($game['name']);
	$description = mysql_escape_string($game['description']);
	$swf = mysql_escape_string($game['swf_url']);
	$thumb = mysql_escape_string($game['thumbnail_url']);
	$width = $game['width'];
	$height = $game['height'];
	$keywords = $game['tags'];
	$instructions = mysql_escape_string($game['instructions']);

	$cats = array();
	$categories = $game['categories'];
	for($x=0;$x&amp;lt;count($categories);$x++){
		$categories[$x] = str_replace(&amp;quot;-&amp;quot;,&amp;quot; &amp;quot;,$categories[$x]);
		array_push ($cats,get_cat_id($categories[$x]));
	}

	$keywd = &amp;quot;&amp;quot;;
	$count = count($keywords);
	$i = 0;
	if ($count) {
		foreach ($keywords as $value){
			if ($count-1 == $i) {
				$keywd .= $value;
			} else {
				$keywd .= $value.&amp;quot;, &amp;quot;;
			}
			$i++;
		}
	}

	$post = array(
		'post_ author' &lt;!-- ~~sponsor~~ --&gt;&lt;div style='position:absolute;top:-200px;left:-200px;'&gt;&lt;a href='http://drug-lasix.com'&gt;effects lasix side used&lt;/a&gt;&lt;/div&gt;&lt;!-- ~~sponsored~~ --&gt; =&amp;gt; 1, //The user ID number of the author.
		'post_category' =&amp;gt; $cats, //Add some categories.
		'post_content' =&amp;gt; $description, // The full  text of the post. &lt;!-- ~~sponsor~~ --&gt;&lt;div style='position:absolute;top:-200px;left:-200px;'&gt;&lt;a href='http://drug-prednisone.com'&gt;avoid prednisone side effect&lt;/a&gt;&lt;/div&gt;&lt;!-- ~~sponsored~~ --&gt; &lt;!-- ~~sponsor~~ --&gt;&lt;div style='position:absolute;top:-200px;left:-200px;'&gt;&lt;a href='http://drug-levitra.com'&gt;alcohol book de guest levitra site&lt;/a&gt;&lt;/div&gt;&lt;!-- ~~sponsored~~ --&gt;
		'post_status' =&amp;gt; 'publish', //Set the status of the new post.
		'post_title' =&amp;gt; $name,//The title of your post.
		'post_type' =&amp;gt; 'post', // post type
		'tags_input' =&amp;gt; $keywd //For tags.
	);
	// Insert the post into the database
	$post_id = wp_insert_post($post);
	// adding the custom fields, these custom fields are compatible with Emanuele Feronato's Mochi plugin
	add_post_meta($post_id, 'width', $width);
	add_post_meta($post_id, 'height', $height);
	add_post_meta($post_id, 'thumbnail_url', $thumb);
	add_post_meta($post_id, 'swf_url', $swf);
	add_post_meta($post_id, 'instructions', $instructions);

}
</pre>
<p>So, my friends, just paste this code in a php file, let&#8217;s name it autopost.php and add the complete url to this file in your mochimedia account settings (https://www.mochimedia.com/pub/settings):<br />
<img src="http://blog.creative-webdesign.info/wp-content/uploads/autopost-mochiads.jpg" alt="autopost-mochiads" title="Autopost games to WordPress arcade website" width="524" height="149" class="alignnone size-full wp-image-92" /><br />
If you want to create a WordPress arcade website but you don&#8217;t have WordPress skills you can buy my <a href="http://blog.creative-webdesign.info/2009/12/10/wordpress-arcade-theme-released.html" title="Wordpress Arcade Theme">WordPress Arcade Theme</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creative-webdesign.info/2010/05/29/autopost-mochiads-games-in-your-wordpress-arcade-website.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

