entirely possible media/links were the only thing posted - don't forward empty message to twitter/SN
This commit is contained in:
parent
2e78ed00f6
commit
a18bb816cd
2 changed files with 20 additions and 18 deletions
|
@ -235,7 +235,8 @@ function statusnet_post_hook(&$a,&$b) {
|
||||||
$msg .= '... ' . $shortlink;
|
$msg .= '... ' . $shortlink;
|
||||||
}
|
}
|
||||||
// and now tweet it :-)
|
// and now tweet it :-)
|
||||||
$dent->post('statuses/update', array('status' => $msg));
|
if(strlen($msg))
|
||||||
|
$dent->post('statuses/update', array('status' => $msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,30 +188,31 @@ function twitter_post_hook(&$a,&$b) {
|
||||||
$tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
|
$tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
|
||||||
$max_char = 140; // max. length for a tweet
|
$max_char = 140; // max. length for a tweet
|
||||||
$msg = strip_tags(bbcode($b['body']));
|
$msg = strip_tags(bbcode($b['body']));
|
||||||
if ( strlen($msg) > $max_char) {
|
if ( strlen($msg) > $max_char) {
|
||||||
$shortlink = "";
|
$shortlink = "";
|
||||||
require_once('addon/twitter/slinky.php');
|
require_once('addon/twitter/slinky.php');
|
||||||
// post url = base url + /display/ + owner + post id
|
// post url = base url + /display/ + owner + post id
|
||||||
// we construct this from the Owner link and replace
|
// we construct this from the Owner link and replace
|
||||||
// profile by display - this will cause an error when
|
// profile by display - this will cause an error when
|
||||||
// /profile/ is in the owner url twice but I don't
|
// /profile/ is in the owner url twice but I don't
|
||||||
// think this will be very common...
|
// think this will be very common...
|
||||||
$posturl = str_replace('/profile/','/display/',$b['owner-link']).'/'.$b['id'];
|
$posturl = str_replace('/profile/','/display/',$b['owner-link']).'/'.$b['id'];
|
||||||
$slinky = new Slinky( $posturl );
|
$slinky = new Slinky( $posturl );
|
||||||
// setup a cascade of shortening services
|
// setup a cascade of shortening services
|
||||||
// try to get a short link from these services
|
// try to get a short link from these services
|
||||||
// in the order ur1.ca, trim, id.gd, tinyurl
|
// 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() ) );
|
$slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) );
|
||||||
$shortlink = $slinky->short();
|
$shortlink = $slinky->short();
|
||||||
// the new message will be shortened such that "... $shortlink"
|
// the new message will be shortened such that "... $shortlink"
|
||||||
// will fit into the character limit
|
// will fit into the character limit
|
||||||
$msg = substr($msg, 0, $max_char-strlen($shortlink)-4);
|
$msg = substr($msg, 0, $max_char-strlen($shortlink)-4);
|
||||||
$msg .= '... ' . $shortlink;
|
$msg .= '... ' . $shortlink;
|
||||||
}
|
}
|
||||||
// and now tweet it :-)
|
// and now tweet it :-)
|
||||||
$tweet->post('statuses/update', array('status' => $msg));
|
if(strlen($msg))
|
||||||
|
$tweet->post('statuses/update', array('status' => $msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue