facebook and gofresh and itsmy integrating an html5 game into facebook world

15
Integrating an HTML5 Mobile Casual Social Game Into The World of Facebook Mobile [email protected]

Upload: mobilemonday

Post on 10-May-2015

1.629 views

Category:

Technology


5 download

DESCRIPTION

Presentation at http://www.mobile-monday.de/events/kick-ass-m2d2-developing-facebook-html5-mobile-games-apps

TRANSCRIPT

Page 1: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Integrating an HTML5 Mobile Casual Social Game

IntoThe World of Facebook Mobile

[email protected]

Page 2: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

The MoMo Battle Pokerhttp://m.itsmy.com/poker/

Page 3: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Integration steps

• Register and configure a Facebook Application– http://developer.facebook.com/apps

• Implement Facebook Javascript SDK

• Authentication & permissions

• Graph API – get some data from Facebook

Page 4: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Integration steps

• Integrate Social Channels– Invite friends

– Post Highscores

– Timeline achievements with Open Graph

• Payment Integration– Application settings

– Backend

– Frontend FB calls

Page 5: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

URLs

All documentatios & demos

https://developers.facebook.com/docs/guides/mobile/web/

MoMo battle poker

http://m.itsmy.com/poker/

Page 6: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Register & configure Facebook App

https://developers.facebook.com/apps

Page 7: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Implement Javascript SDK

<div id="fb-root"></div>

<script>

// Load the SDK Asynchronously

(function(d){

var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];

if (d.getElementById(id)) {return;}

js = d.createElement('script'); js.id = id; js.async = true;

js.src = "//connect.facebook.net/en_US/all.js";

ref.parentNode.insertBefore(js, ref);

}(document));

window.fbAsyncInit = function() {

FB.init({

appId : 'YOUR_APP_ID', // App ID

channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File

status : true, // check login status

cookie : true, // enable cookies to allow the server to access the session

xfbml : true // parse XFBML

});

FB.Event.subscribe('auth.statusChange', handleStatusChange);

};

</script>

Page 8: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Login & Authentication

function handleStatusChange(response)

{

document.body.className = response.authResponse ? 'connected' : 'not_connected';

if (response.authResponse)

{

console.log(response);

updateUserInfo(response);

}

}

Page 9: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Login button

<div id="login"><div class="round_button gameButton play"><a class="poker activeLink" href="#" onClick="loginUser();">Connect to Facebook</a></div>

</div><script>function loginUser(){FB.login(function(response) { }, {scope:'email'});

}</script>

Page 10: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Successful login – Show user

<script>function updateUserInfo(response){//Graph APIFB.api('/me', function(response){document.getElementById('user-info-box').style.display = '';document.getElementById('user-info').innerHTML = '<img class="round_button" src="https://graph.facebook.com/' + response.id + '/picture">';document.getElementById('user-info-name').innerHTML = response.first_name;document.getElementById('fbuid').innerHTML = response.id;

});}</script>

Page 11: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Invite

<div class="round_button gameButton play"><a class="poker activeLink" href="#" onclick="invite();return false;">Invite</a>

</div><script>function invite(){FB.ui({method: 'apprequests',message: 'Challenge: Play 10 hands of poker and beat my highscore',}, function(response){console.log('sendRequest response: ', response);});

}</script>

Page 12: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Highscore

Server Side Graph API call

CURL -F access_token=xxxxyyyyy-F new_high_score=3400‚-F game=http://samples.ogp.me/163382137069945https://graph.facebook.com/me/games.high_score

Page 13: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Open GraphAchievements @ timeline

Open Graph – Object

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xmlns:fb="https://www.facebook.com/2008/fbml">

<head prefix="og: http://ogp.me/ns# momopoker: http://ogp.me/ns/apps/momopoker#"><title>ACHIEVEMENT NAME</title><meta property="fb:app_id" content="407286962618956" /><meta property="og:type" content="momopoker:trophy"/><meta property="og:title" content=“ACHIEVEMENT NAME"/><meta property="og:image" content="http://m.itsmy.com/images/trophy.png"/><meta property="og:description" content=“ACHIEVEMENT DESCRIPTION"/><meta property="og:url" content="http://m.itsmy.com/poker/fb_achievements.php?16"/></head><body><script type="text/javascript">window.location='/poker/index.php';

</script></body></html>

Page 14: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

Open GraphAchievements @ timeline

Graph API – Call

FB.api('/me/momopoker:achieve?trophy=http://m.itsmy.com/poker/fb_achievements.php?21,'post',function(response) {if (!response || response.error) {

console.log(response);

} else {alert('achievement was successful! Action ID: ' + response.id);

}});

Page 15: Facebook and GoFresh and itsmy integrating an HTML5 game into Facebook world

ITSMY GamesGofresh GmbH

handcrafted since

2010Lilienstrasse 1 81669 Munich / GermanyTel. +49 89 6230 3730

[email protected]