Support for attachments in the API (for better AndStatus support)
This commit is contained in:
parent
d80c375220
commit
26d5746d99
|
@ -886,12 +886,15 @@
|
||||||
'in_reply_to_screen_name' => $in_reply_to_screen_name,
|
'in_reply_to_screen_name' => $in_reply_to_screen_name,
|
||||||
'geo' => NULL,
|
'geo' => NULL,
|
||||||
'favorited' => $lastwall['starred'] ? true : false,
|
'favorited' => $lastwall['starred'] ? true : false,
|
||||||
// attachments
|
'attachments' => api_get_attachments($lastwall['body']),
|
||||||
'user' => $user_info,
|
'user' => $user_info,
|
||||||
'statusnet_html' => trim(bbcode($lastwall['body'], false, false)),
|
'statusnet_html' => trim(bbcode($lastwall['body'], false, false)),
|
||||||
'statusnet_conversation_id' => $lastwall['parent'],
|
'statusnet_conversation_id' => $lastwall['parent'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!$status_info["attachments"])
|
||||||
|
unset($status_info["attachments"]);
|
||||||
|
|
||||||
if ($lastwall['title'] != "")
|
if ($lastwall['title'] != "")
|
||||||
$status_info['statusnet_html'] = "<h4>".bbcode($lastwall['title'])."</h4>\n".$status_info['statusnet_html'];
|
$status_info['statusnet_html'] = "<h4>".bbcode($lastwall['title'])."</h4>\n".$status_info['statusnet_html'];
|
||||||
|
|
||||||
|
@ -985,10 +988,14 @@
|
||||||
'in_reply_to_screen_name' => $in_reply_to_screen_name,
|
'in_reply_to_screen_name' => $in_reply_to_screen_name,
|
||||||
'geo' => NULL,
|
'geo' => NULL,
|
||||||
'favorited' => $lastwall['starred'] ? true : false,
|
'favorited' => $lastwall['starred'] ? true : false,
|
||||||
|
'attachments' => api_get_attachments($lastwall['body']),
|
||||||
'statusnet_html' => trim(bbcode($lastwall['body'], false, false)),
|
'statusnet_html' => trim(bbcode($lastwall['body'], false, false)),
|
||||||
'statusnet_conversation_id' => $lastwall['parent'],
|
'statusnet_conversation_id' => $lastwall['parent'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!$user_info["attachments"])
|
||||||
|
unset($user_info["attachments"]);
|
||||||
|
|
||||||
if ($lastwall['title'] != "")
|
if ($lastwall['title'] != "")
|
||||||
$user_info['statusnet_html'] = "<h4>".bbcode($lastwall['title'])."</h4>\n".$user_info['statusnet_html'];
|
$user_info['statusnet_html'] = "<h4>".bbcode($lastwall['title'])."</h4>\n".$user_info['statusnet_html'];
|
||||||
|
|
||||||
|
@ -1803,6 +1810,30 @@
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function api_get_attachments($text) {
|
||||||
|
|
||||||
|
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $text);
|
||||||
|
|
||||||
|
$URLSearchString = "^\[\]";
|
||||||
|
$ret = preg_match_all("/\[img\]([$URLSearchString]*)\[\/img\]/ism", $text, $images);
|
||||||
|
|
||||||
|
if (!$ret)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
require_once("include/Photo.php");
|
||||||
|
|
||||||
|
$attachments = array();
|
||||||
|
|
||||||
|
foreach ($images[1] AS $image) {
|
||||||
|
$imagedata = get_photo_info($image);
|
||||||
|
|
||||||
|
if ($imagedata)
|
||||||
|
$attachments[] = array("url" => $image, "mimetype" => $imagedata["mime"], "size" => $imagedata["size"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $attachments;
|
||||||
|
}
|
||||||
|
|
||||||
function api_get_entitities(&$text, $bbcode) {
|
function api_get_entitities(&$text, $bbcode) {
|
||||||
/*
|
/*
|
||||||
To-Do:
|
To-Do:
|
||||||
|
@ -2059,13 +2090,16 @@
|
||||||
'in_reply_to_screen_name' => $in_reply_to_screen_name,
|
'in_reply_to_screen_name' => $in_reply_to_screen_name,
|
||||||
'geo' => NULL,
|
'geo' => NULL,
|
||||||
'favorited' => $item['starred'] ? true : false,
|
'favorited' => $item['starred'] ? true : false,
|
||||||
//'attachments' => array(),
|
'attachments' => api_get_attachments($item["body"]),
|
||||||
'user' => $status_user ,
|
'user' => $status_user ,
|
||||||
//'entities' => NULL,
|
//'entities' => NULL,
|
||||||
'statusnet_html' => $statushtml,
|
'statusnet_html' => $statushtml,
|
||||||
'statusnet_conversation_id' => $item['parent'],
|
'statusnet_conversation_id' => $item['parent'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!$status["attachments"])
|
||||||
|
unset($status["attachments"]);
|
||||||
|
|
||||||
if ($item['title'] != "")
|
if ($item['title'] != "")
|
||||||
$status['statusnet_html'] = "<h4>".bbcode($item['title'])."</h4>\n".$status['statusnet_html'];
|
$status['statusnet_html'] = "<h4>".bbcode($item['title'])."</h4>\n".$status['statusnet_html'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue