From 50c33d8dc25f19c10cf0f1cf15ed6daa0b76055f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 22 Nov 2012 03:31:43 +0100 Subject: [PATCH] fbpost: Posting to groups enabled twitter/statusnet: Bug fixed where messages were shortened too much. --- fbpost/fbpost.php | 20 ++++++++++++++++---- statusnet/statusnet.php | 2 +- twitter/twitter.php | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index 01311320..8c45d004 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -209,7 +209,7 @@ function fbpost_content(&$a) { $o .= '
'; $o .= '' . t('Install Facebook Post connector for this account.') . ''; + . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=publish_stream,manage_pages,user_groups,friends_groups,offline_access">' . t('Install Facebook Post connector for this account.') . ''; $o .= '
'; } @@ -221,7 +221,7 @@ function fbpost_content(&$a) { $o .= '
'; $o .= '' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . ''; + . $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=publish_stream,manage_pages,user_groups,friends_groups,offline_access">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . ''; $o .= '
'; $o .= '
'; @@ -242,7 +242,7 @@ function fbpost_content(&$a) { $x = file_get_contents($url."?access_token=".$fb_token); $accounts = json_decode($x); - $o .= t("Post to page:").""; if (intval($post_to_page) == 0) $o .= ""; else @@ -255,6 +255,18 @@ function fbpost_content(&$a) { else $o .= ""; } + + $url = 'https://graph.facebook.com/me/groups'; + $x = file_get_contents($url."?access_token=".$fb_token); + $groups = json_decode($x); + + foreach($groups->data as $group) { + if ($post_to_page == $group->id) + $o .= ""; + else + $o .= ""; + } + $o .= ""; $o .= '

'; @@ -661,7 +673,7 @@ function fbpost_post_hook(&$a,&$b) { } // Post to page? - if (!$reply and $target != "me") + if (!$reply and ($target != "me") and $page_access_token) $postvars['access_token'] = $page_access_token; logger('facebook: post to ' . $url); diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index bdbb4d4a..3bbe4171 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -495,7 +495,7 @@ function statusnet_shortenmsg($b, $max_char) { $msg = substr($msg, 0, -1); $pos = strrpos($msg, "\n"); if ($pos > 0) - $msg = substr($msg, 0, $pos-1); + $msg = substr($msg, 0, $pos); else if ($lastchar != "\n") $msg = substr($msg, 0, -3)."..."; } diff --git a/twitter/twitter.php b/twitter/twitter.php index 3fcaa1de..6a93d9f1 100755 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -354,7 +354,7 @@ function twitter_shortenmsg($b) { $msg = substr($msg, 0, -1); $pos = strrpos($msg, "\n"); if ($pos > 0) - $msg = substr($msg, 0, $pos-1); + $msg = substr($msg, 0, $pos); else if ($lastchar != "\n") $msg = substr($msg, 0, -3)."..."; }