forked from GNUsocial/gnu-social
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
This commit is contained in:
parent
1e746da545
commit
071d6e72e0
@ -81,9 +81,20 @@ class FacebookAction extends Action
|
|||||||
|
|
||||||
function showStylesheets()
|
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', 'base');
|
||||||
$this->cssLink('css/display.css', null, 'screen, projection, tv');
|
$this->cssLink('css/display.css', null, 'screen, projection, tv');
|
||||||
$this->cssLink('plugins/Facebook/facebookapp.css');
|
$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()
|
function showScripts()
|
||||||
@ -292,31 +303,6 @@ class FacebookAction extends Action
|
|||||||
$this->elementEnd('div');
|
$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 = '<style> .entry-title *, .entry-content * { font-size:14px; font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; } .entry-title a, .entry-content a { color:#002E6E; } .entry-title .vcard .photo { float:left; display:inline; margin-right:11px; margin-bottom:11px } .entry-title { margin-bottom:11px; } .entry-title p.entry-content { display:inline; margin-left:5px; } div.entry-content { clear:both; } div.entry-content dl, div.entry-content dt, div.entry-content dd { display:inline; text-transform:lowercase; } div.entry-content dd, div.entry-content .device dt { margin-left:0; margin-right:5px; } div.entry-content dl.timestamp dt, div.entry-content dl.response dt { display:none; } div.entry-content dd a { display:inline-block; } #facebook_statusnet_app { text-indent:-9999px; height:16px; width:16px; display:block; background:url('.$icon_url.') no-repeat 0 0; float:right; } </style>';
|
|
||||||
|
|
||||||
$this->xw->openMemory();
|
|
||||||
|
|
||||||
$item = new FacebookProfileBoxNotice($notice, $this);
|
|
||||||
$item->show();
|
|
||||||
|
|
||||||
$fbml = "<fb:wide>$style " . $this->xw->outputMemory(false) . "</fb:wide>";
|
|
||||||
$fbml .= "<fb:narrow>$style " . $this->xw->outputMemory(false) . "</fb:narrow>";
|
|
||||||
|
|
||||||
$fbml_main = "<fb:narrow>$style " . $this->xw->outputMemory(false) . "</fb:narrow>";
|
|
||||||
|
|
||||||
$this->facebook->api_client->profile_setFBML(null, $this->fbuid, $fbml, null, null, $fbml_main);
|
|
||||||
|
|
||||||
$this->xw->openURI('php://output');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate pagination links
|
* Generate pagination links
|
||||||
*
|
*
|
||||||
|
@ -44,33 +44,15 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
// If the user has opted not to initially allow the app to have
|
if (!empty($this->flink)) {
|
||||||
// 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) {
|
|
||||||
$this->user = $this->flink->getUser();
|
$this->user = $this->flink->getUser();
|
||||||
|
|
||||||
// If this is the first time the user has started the app
|
// If this is the first time the user has started the app
|
||||||
// prompt for Facebook status update permission
|
// prompt for Facebook status update permission
|
||||||
if (!$this->facebook->api_client->users_hasAppPermission('publish_stream')) {
|
if (!$this->facebook->api_client->users_hasAppPermission('publish_stream')) {
|
||||||
|
|
||||||
if ($this->facebook->api_client->data_getUserPreference(
|
|
||||||
FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') {
|
|
||||||
$this->getUpdatePermission();
|
$this->getUpdatePermission();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the user's profile box has the lastest notice
|
|
||||||
$notice = $this->user->getCurrentNotice();
|
|
||||||
if ($notice) {
|
|
||||||
$this->updateProfileBox($notice);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->arg('status_submit') == 'Send') {
|
if ($this->arg('status_submit') == 'Send') {
|
||||||
$this->saveNewNotice();
|
$this->saveNewNotice();
|
||||||
@ -114,8 +96,6 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
|
|
||||||
// XXX: Do some error handling here
|
// XXX: Do some error handling here
|
||||||
|
|
||||||
$this->setDefaults();
|
|
||||||
|
|
||||||
$this->getUpdatePermission();
|
$this->getUpdatePermission();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -127,12 +107,6 @@ class FacebookhomeAction extends FacebookAction
|
|||||||
$this->showFooter();
|
$this->showFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefaults()
|
|
||||||
{
|
|
||||||
$this->facebook->api_client->data_setUserPreference(
|
|
||||||
FACEBOOK_PROMPTED_UPDATE_PREF, 'false');
|
|
||||||
}
|
|
||||||
|
|
||||||
function showNoticeForm()
|
function showNoticeForm()
|
||||||
{
|
{
|
||||||
$post_action = "$this->app_uri/index.php";
|
$post_action = "$this->app_uri/index.php";
|
||||||
|
@ -50,6 +50,7 @@ function getFacebook()
|
|||||||
|
|
||||||
function isFacebookBound($notice, $flink) {
|
function isFacebookBound($notice, $flink) {
|
||||||
if (empty($flink)) {
|
if (empty($flink)) {
|
||||||
|
common_debug("QQQQQ empty flink");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,11 +158,6 @@ function facebookBroadcastNotice($notice)
|
|||||||
common_log(LOG_WARNING, $msg);
|
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) {
|
} catch (FacebookRestClientException $e) {
|
||||||
return handleFacebookError($e, $notice, $flink);
|
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)
|
function format_attachments($attachments)
|
||||||
{
|
{
|
||||||
$fbattachment = array();
|
$fbattachment = array();
|
||||||
|
Loading…
Reference in New Issue
Block a user