diff options
author | Friendika <info@friendika.com> | 2011-02-10 03:51:42 -0800 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-02-10 03:51:42 -0800 |
commit | a18bb816cd4a0d82b1e2d0f9c456669987ced83b (patch) | |
tree | 985cd9a53667a70efd4f533da84f5a4690ba1fa9 /addon | |
parent | 2e78ed00f6b247c90b1bc78ff4801e337e6d8d86 (diff) | |
download | volse-hubzilla-a18bb816cd4a0d82b1e2d0f9c456669987ced83b.tar.gz volse-hubzilla-a18bb816cd4a0d82b1e2d0f9c456669987ced83b.tar.bz2 volse-hubzilla-a18bb816cd4a0d82b1e2d0f9c456669987ced83b.zip |
entirely possible media/links were the only thing posted - don't forward empty message to twitter/SN
Diffstat (limited to 'addon')
-rw-r--r-- | addon/statusnet/statusnet.php | 3 | ||||
-rw-r--r-- | addon/twitter/twitter.php | 35 |
2 files changed, 20 insertions, 18 deletions
diff --git a/addon/statusnet/statusnet.php b/addon/statusnet/statusnet.php index cd562cd1e..bc47242fc 100644 --- a/addon/statusnet/statusnet.php +++ b/addon/statusnet/statusnet.php @@ -235,7 +235,8 @@ function statusnet_post_hook(&$a,&$b) { $msg .= '... ' . $shortlink; } // and now tweet it :-) - $dent->post('statuses/update', array('status' => $msg)); + if(strlen($msg)) + $dent->post('statuses/update', array('status' => $msg)); } } } diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php index 1cd6ee7e9..a0c6db931 100644 --- a/addon/twitter/twitter.php +++ b/addon/twitter/twitter.php @@ -188,30 +188,31 @@ function twitter_post_hook(&$a,&$b) { $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); $max_char = 140; // max. length for a tweet $msg = strip_tags(bbcode($b['body'])); - if ( strlen($msg) > $max_char) { - $shortlink = ""; - require_once('addon/twitter/slinky.php'); - // post url = base url + /display/ + owner + post id - // we construct this from the Owner link and replace - // profile by display - this will cause an error when - // /profile/ is in the owner url twice but I don't - // think this will be very common... + if ( strlen($msg) > $max_char) { + $shortlink = ""; + require_once('addon/twitter/slinky.php'); + // post url = base url + /display/ + owner + post id + // we construct this from the Owner link and replace + // profile by display - this will cause an error when + // /profile/ is in the owner url twice but I don't + // think this will be very common... $posturl = str_replace('/profile/','/display/',$b['owner-link']).'/'.$b['id']; $slinky = new Slinky( $posturl ); // setup a cascade of shortening services // try to get a short link from these services // in the order ur1.ca, trim, id.gd, tinyurl $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); - $shortlink = $slinky->short(); - // the new message will be shortened such that "... $shortlink" - // will fit into the character limit - $msg = substr($msg, 0, $max_char-strlen($shortlink)-4); - $msg .= '... ' . $shortlink; - } - // and now tweet it :-) - $tweet->post('statuses/update', array('status' => $msg)); + $shortlink = $slinky->short(); + // the new message will be shortened such that "... $shortlink" + // will fit into the character limit + $msg = substr($msg, 0, $max_char-strlen($shortlink)-4); + $msg .= '... ' . $shortlink; + } + // and now tweet it :-) + if(strlen($msg)) + $tweet->post('statuses/update', array('status' => $msg)); } } - } + } } |