From: Zach Copley Date: Mon, 31 Jan 2011 23:42:43 +0000 (+0000) Subject: FacebookPlugin: Fix up FBML canvas app so it keeps working after X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ad12384d8c021c31f91060ccbc4f91eda9d33f02;p=quix0rs-gnu-social.git 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 --- 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();