Skip to content
Browse files

Simplification of platform classes and demo of fb request 2.0.

  • Loading branch information...
1 parent d68153f commit b19acbde69c67bd1e47654cfe4573c30475268c8 @freneticpixel freneticpixel committed
Showing with 44 additions and 125 deletions.
  1. +13 −54 FacebookPlatform.php
  2. +4 −48 KongregatePlatform.php
  3. +21 −19 Platform.php
  4. +6 −4 index.php
View
67 FacebookPlatform.php
@@ -9,6 +9,7 @@ class FacebookPlatform extends Platform {
protected $config;
public function __construct($config) {
+ $this->config = $config;
$this->facebook = new Facebook(array(
'appId' => $config['app_id'],
'secret' => $config['app_secret'],
@@ -17,9 +18,9 @@ public function __construct($config) {
}
public function loadLibraries() {
- $sig = $this->getSessionParams();
- ?>
+ ?>
<div id="fb-root"></div>
+ <div id="iframe_container" style="display:none"></div>
<script type="text/javascript">
var origPostTarget;
window.fbAsyncInit = function() {
@@ -64,7 +65,7 @@ function publishStream(title, message, body, actionText, link, images, target) {
data.attachment.media = [];
var i = 0;
for (var image in images) {
- data.attachment.media[i] = {'type':'image','src':'<?= $this->config['image_root'] ?>/' + images[image],'href':link};
+ data.attachment.media[i] = {'type':'image','src':'images/' + images[image],'href':link};
i++;
}
FB.ui(data, function(response) {
@@ -74,25 +75,15 @@ function publishStream(title, message, body, actionText, link, images, target) {
var attachment = {'media':[], 'name':title, 'caption':body};
}
-
function showInvitePopup() {
- document.getElementById('iframe_container').innerHTML = "<iframe id='syn_iframe' style='border: none;' height='630' width='100%' frameborder='0' scrolling='no' allowtransparency='true' src='request.php?<?=$sig?>'></iframe>";
- $('#iframe_container').show();
+ FB.ui({method: 'apprequests',
+ message: 'You should learn more about this awesome game.',
+ display: 'iframe',
+ data: 'trackingdata'});
}
- function showGiftPopup() {
- document.getElementById('iframe_container').innerHTML = "<iframe id='syn_iframe' style='border: none;' height='630' width='100%' frameborder='0' scrolling='no' allowtransparency='true' src='request.php?type=gift&<?=$sig?>'></iframe>";
- $('#iframe_container').show();
- }
- function closeIframePopup() {
- $('#iframe_container').hide();
- document.getElementById('iframe_container').innerHTML = "";
- return false;
- }
</script>
-
<?php
-
}
public function getSessionParams() {
@@ -116,14 +107,6 @@ public function displayLogout() {
echo "<img src='http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif'></a>";
}
- public function displayHeader() {
-
- }
-
- public function displayFooter() {
-
- }
-
public function getFlashHeight() {
return 660;
}
@@ -363,10 +346,6 @@ public function isStreaming() {
}
}
- public function updateInventory() {
- return true;
- }
-
public function getFeaturedNews() {
$news = array();
$news[] = array('banner' => '5starreviewnewsbanner.png', 'link' => 'http://www.facebook.com/apps/application.php?id=130193190327885&v=app_6261817190');
@@ -375,10 +354,7 @@ public function getFeaturedNews() {
}
public function displayProfilePicture($user_id) {
- ?>
- <img src="http://graph.facebook.com/<?=$user_id?>/picture" height='50' width='50'/>
- <?php
-
+ echo "<img src='http://graph.facebook.com/<?=$user_id?>/picture' height='50' width='50'/>";
}
public function getEmail($uid) {
@@ -429,28 +405,11 @@ public function getUidFromThirdPartyID($tpi) {
return $uid;
}
- // Stubbed
- public function addUserActivity($data) {
-
- }
-
- public function publishUserAction($data) {
-
- }
-
- public function displayInviteBox($data) {
-
- }
-
- public function publishStats($key, $value) {
-
- }
-
public function isFeatureEnabled($feature) {
- /*switch($feature) {
- case 'boosts':
- return false;
- }*/
+ switch($feature) {
+ case"stats":
+ return false;
+ }
return true;
}
View
52 KongregatePlatform.php
@@ -24,14 +24,6 @@ public function loadLibraries() {
echo "<script type='text/javascript' src='http://www.kongregate.com/javascripts/kongregate_api.js'></script>";
}
- public function displayHeader() {
-
- }
-
- public function displayFooter() {
-
- }
-
public function getFlashHeight() {
return 580;
}
@@ -113,14 +105,6 @@ public function isLoggedIn() {
return true;
}
- public function displayLogin() {
-
- }
-
- public function displayLogout() {
-
- }
-
public function getUser() {
if (!isset($this->user)) {
$this->user = $this->login();
@@ -133,18 +117,6 @@ public function getUserName() {
return $name;
}
- public function addUserActivity($data) {
-
- }
-
- public function publishUserAction($data) {
-
- }
-
- public function displayInviteBox($data) {
-
- }
-
public function getUserInfo($user_id, $fields) {
return false;
@@ -182,14 +154,6 @@ public function isStreaming() {
return true;
}
- public function displayProfilePicture($user_id) {
-
- }
-
- public function displayName($user_id) {
-
- }
-
public function getRequestListLink() {
return false;
}
@@ -211,7 +175,6 @@ public function getName($user_id) {
return $_REQUEST['kongregate_username'];
}
-
protected function getKredsInventory() {
return self::getRemoteData("http://www.kongregate.com/api/user_items.json?api_key={$this->config['app_secret']}&user_id={$this->user}");
}
@@ -256,11 +219,6 @@ public function updateInventory() {
return true;
}
- public function getFeaturedNews() {
- $news = array();
- $news[] = array('banner' => '5star.jpg');
- return $news;
- }
public function publishStats($key, $value) {
$apiCall = "http://www.kongregate.com/api/submit_statistics.json?api_key={$this->config['app_secret']}&user_id={$this->user}&game_auth_token={$this->game_auth_token}";
@@ -268,15 +226,13 @@ public function publishStats($key, $value) {
$this->getRemoteData($apiCall);
}
-
public function isFeatureEnabled($feature) {
- /*switch($feature) {
- case 'boosts':
- return false;
- }*/
+ switch($feature) {
+ case 'invites':
+ return false;
+ }
return true;
}
}
-
?>
View
40 Platform.php
@@ -5,16 +5,19 @@
// AUTHENTICATION
abstract public function loadLibraries();
+ abstract public function login();
+ abstract public function isLoggedIn();
+ abstract public function getUser();
+
public function getSessionParams() {}
- abstract public function getUser();
- abstract public function login();
- abstract public function isLoggedIn();
+
// USER API CALLS
abstract public function getUserName();
+ abstract public function getName($user_id);
+
public function displayProfilePicture($user_id) {}
public function displayName($user_id) {}
- abstract public function getName($user_id);
abstract public function getUserInfo($user_id, $fields);
abstract public function getFriends();
abstract public function getFriendsAppUsers();
@@ -23,23 +26,22 @@ public function displayName($user_id) {}
// LAYOUT/CONTENT
- abstract public function displayLogin();
- abstract public function displayLogout();
- abstract public function displayHeader();
- abstract public function displayFooter();
-
- abstract public function getFlashHeight();
- abstract public function getFlashParams();
- abstract public function displayFlashFile();
-
- abstract public function getRequestListLink();
- abstract public function getAppInfoPage();
- abstract public function getAppNewsfeedPage();
- abstract public function getAppForums();
-
abstract public function isFeatureEnabled($feature_id);
+ public function displayLogin(){}
+ public function displayLogout(){}
+ public function displayHeader(){}
+ public function displayFooter(){}
+
+ public function getFlashHeight(){}
+ public function getFlashParams(){}
+ public function displayFlashFile(){}
+
+ public function getRequestListLink(){}
+ public function getAppInfoPage(){}
+ public function getAppNewsfeedPage(){}
+ public function getAppForums(){}
-
+
// PLATFORM API
public function getEmail($uid){}
public function getThirdPartyID($uid){}
View
10 index.php
@@ -1,18 +1,17 @@
<?php
-error_reporting(E_ALL & E_STRICT);
+error_reporting(E_ALL);
+$config = array();
if (isset($_REQUEST['platform']) && $_REQUEST['platform'] == "fb") {
require_once("FacebookPlatform.php");
- $config = array();
$config['app_id'] = "211399198872054";
$config['app_secret'] = "1ba40f64224da013c9b42a584d001dd8";
$config['app_root'] = "http://dev.tyrantonline.com/platformdemo/?platform=fb";
$config['server_root'] = "http://dev.tyrantonline.com/platformdemo";
- $platform = new FacebookPlatform($config);
+ $platform = new FacebookPlatform($config);
} else {
require_once("KongregatePlatform.php");
- $config = array();
$config['app_id'] = "108711";
$config['app_secret'] = "5f58de78-c989-49cd-948a-af423ff222bf";
$config['app_root'] = "http://www.kongregate.com/games/freneticpixel/platform-demo_preview/";
@@ -32,5 +31,8 @@
<body>
<?= $platform->displayHeader();?>
<h1>Hello <?= $platform->getUserName()?>!</h1>
+<?php if ($platform->isFeatureEnabled("invites")) { ?>
+<a onclick='showInvitePopup();' href="#">Invite a Friend!</a>
+<?php }?>
<?= $platform->displayFooter();?>
</body>

0 comments on commit b19acbd

Please sign in to comment.
Something went wrong with that request. Please try again.