From 071d6e72e0c3c7b1d9fe8d75f30a43831fe54edd Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 31 Jan 2011 23:42:43 +0000 Subject: [PATCH] FacebookPlugin: Fix up FBML canvas app so it keeps working after Facebook removed Profile Boxes and some API calls it relied upon. See: http://developers.facebook.com/roadmap/deprecations --- plugins/Facebook/facebookaction.php | 36 +++++++++-------------------- plugins/Facebook/facebookhome.php | 34 ++++----------------------- plugins/Facebook/facebookutil.php | 33 +------------------------- 3 files changed, 16 insertions(+), 87 deletions(-) diff --git a/plugins/Facebook/facebookaction.php b/plugins/Facebook/facebookaction.php index e4edcea0d9..003bf8cd7e 100644 --- a/plugins/Facebook/facebookaction.php +++ b/plugins/Facebook/facebookaction.php @@ -81,9 +81,20 @@ class FacebookAction extends Action function showStylesheets() { + // Loading CSS via files in Facebook FBML Canvas apps is still busted as of 1/31/11 + // See: http://bugs.developers.facebook.net/show_bug.cgi?id=10052 $this->cssLink('css/display.css', 'base'); $this->cssLink('css/display.css', null, 'screen, projection, tv'); $this->cssLink('plugins/Facebook/facebookapp.css'); + + // Also, Facebook refuses to let me do this... gar! +/* + $baseCss = file_get_contents(INSTALLDIR . '/theme/base/css/display.css'); + $this->style($baseCss); + + $facebookCss = file_get_contents(INSTALLDIR . '/plugins/Facebook/facebookapp.css'); + $this->style($facebookCss); +*/ } function showScripts() @@ -292,31 +303,6 @@ class FacebookAction extends Action $this->elementEnd('div'); } - function updateProfileBox($notice) - { - - // Need to include inline CSS for styling the Profile box - - $app_props = $this->facebook->api_client->Admin_getAppProperties(array('icon_url')); - $icon_url = $app_props['icon_url']; - - $style = ''; - - $this->xw->openMemory(); - - $item = new FacebookProfileBoxNotice($notice, $this); - $item->show(); - - $fbml = "$style " . $this->xw->outputMemory(false) . ""; - $fbml .= "$style " . $this->xw->outputMemory(false) . ""; - - $fbml_main = "$style " . $this->xw->outputMemory(false) . ""; - - $this->facebook->api_client->profile_setFBML(null, $this->fbuid, $fbml, null, null, $fbml_main); - - $this->xw->openURI('php://output'); - } - /** * Generate pagination links * diff --git a/plugins/Facebook/facebookhome.php b/plugins/Facebook/facebookhome.php index 8b8b974458..9b18a695bf 100644 --- a/plugins/Facebook/facebookhome.php +++ b/plugins/Facebook/facebookhome.php @@ -44,33 +44,15 @@ class FacebookhomeAction extends FacebookAction { parent::handle($args); - // If the user has opted not to initially allow the app to have - // Facebook status update permission, store that preference. Only - // promt the user the first time she uses the app - if ($this->arg('skip') || $args['fb_sig_request_method'] == 'GET') { - $this->facebook->api_client->data_setUserPreference( - FACEBOOK_PROMPTED_UPDATE_PREF, 'true'); - } - - if ($this->flink) { + if (!empty($this->flink)) { $this->user = $this->flink->getUser(); // If this is the first time the user has started the app // prompt for Facebook status update permission if (!$this->facebook->api_client->users_hasAppPermission('publish_stream')) { - - if ($this->facebook->api_client->data_getUserPreference( - FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') { - $this->getUpdatePermission(); - return; - } - } - - // Make sure the user's profile box has the lastest notice - $notice = $this->user->getCurrentNotice(); - if ($notice) { - $this->updateProfileBox($notice); - } + $this->getUpdatePermission(); + return; + } if ($this->arg('status_submit') == 'Send') { $this->saveNewNotice(); @@ -114,8 +96,6 @@ class FacebookhomeAction extends FacebookAction // XXX: Do some error handling here - $this->setDefaults(); - $this->getUpdatePermission(); return; } else { @@ -127,12 +107,6 @@ class FacebookhomeAction extends FacebookAction $this->showFooter(); } - function setDefaults() - { - $this->facebook->api_client->data_setUserPreference( - FACEBOOK_PROMPTED_UPDATE_PREF, 'false'); - } - function showNoticeForm() { $post_action = "$this->app_uri/index.php"; diff --git a/plugins/Facebook/facebookutil.php b/plugins/Facebook/facebookutil.php index fb70c51bc5..3996459a63 100644 --- a/plugins/Facebook/facebookutil.php +++ b/plugins/Facebook/facebookutil.php @@ -50,6 +50,7 @@ function getFacebook() function isFacebookBound($notice, $flink) { if (empty($flink)) { + common_debug("QQQQQ empty flink"); return false; } @@ -157,11 +158,6 @@ function facebookBroadcastNotice($notice) common_log(LOG_WARNING, $msg); } - // Finally, attempt to update the user's profile box - if ($canPublish == 1 || $canUpdate == 1) { - updateProfileBox($facebook, $flink, $notice, $user); - } - } catch (FacebookRestClientException $e) { return handleFacebookError($e, $notice, $flink); } @@ -293,33 +289,6 @@ function publishStream($notice, $user, $fbuid) ); } -function updateProfileBox($facebook, $flink, $notice, $user) { - - $facebook = getFacebook(); - $fbaction = new FacebookAction( - $output = 'php://output', - $indent = null, - $facebook, - $flink - ); - - $fbuid = $flink->foreign_id; - - common_debug( - 'FacebookPlugin - Attempting to update profile box with ' - . "content from notice $notice->id for $user->nickname ($user->id), " - . "Facebook UID: $fbuid" - ); - - $fbaction->updateProfileBox($notice); - - common_debug( - 'FacebookPlugin - finished updating profile box for ' - . "$user->nickname ($user->id) Facebook UID: $fbuid" - ); - -} - function format_attachments($attachments) { $fbattachment = array(); -- 2.39.5