$connection->setTimeouts(10, 30);
$max_char = 280;
+
+ $b['body'] = twitter_update_mentions($b['body']);
+
$msgarr = ItemContent::getPlaintextPost($b, $max_char, true, 8);
$msg = $msgarr["text"];
return !isset($result->errors);
}
+
+function twitter_update_mentions($body)
+{
+ $URLSearchString = "^\[\]";
+ $return = preg_replace_callback(
+ "/@\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ function ($matches) {
+ if (strpos($matches[1], 'twitter.com')) {
+ $return = '@' . substr($matches[1], strrpos($matches[1], '/') + 1);
+ } else {
+ $return = $matches[2] . ' (' . $matches[1] . ')';
+ }
+
+ return $return;
+ },
+ $body
+ );
+
+ return $return;
+}