$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)."...";
}
while (strpos($msg, " ") !== false)
$msg = str_replace(" ", " ", $msg);
- return(trim($msg." ".$msglink));
+ return(array("msg"=>trim($msg." ".$msglink), "image"=>$image));
}
function statusnet_post_hook(&$a,&$b) {
// information during shortening of potential links but do not
// shorten all the links in a 200000 character long essay.
+ $tempfile = "";
$intelligent_shortening = get_config('statusnet','intelligent_shortening');
if (!$intelligent_shortening) {
if (! $b['title']=='') {
}
$msg = trim($msg);
- } else
- $msg = statusnet_shortenmsg($b, $max_char);
+ $postdata = array('status' => $msg);
+ } else {
+ $msgarr = statusnet_shortenmsg($b, $max_char);
+ $msg = $msgarr["msg"];
+ $image = $msgarr["image"];
+ if ($image != "") {
+ $imagedata = file_get_contents($image);
+ $tempfile = tempnam("", "upload");
+ file_put_contents($tempfile, $imagedata);
+ $postdata = array("status"=>$msg, "media"=>"@".$tempfile);
+ } else
+ $postdata = array("status"=>$msg);
+ }
// and now dent it :-)
if(strlen($msg)) {
- $result = $dent->post('statuses/update', array('status' => $msg));
+ //$result = $dent->post('statuses/update', array('status' => $msg));
+ $result = $dent->post('statuses/update', $postdata);
logger('statusnet_post send, result: ' . print_r($result, true).
- "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b));
+ "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b)."\nPost Data: ".print_r($postdata));
if ($result->error) {
logger('Send to StatusNet failed: "' . $result->error . '"');
}
}
+ if ($tempfile != "")
+ unlink($tempfile);
}
}